fork download
  1. #include <stdio.h>
  2. #include <stdlib.h> // For exit()
  3.  
  4. int main() {
  5. // Print the process ID using printf
  6. printf("Current Process ID: %d\n", (int)getpid());
  7.  
  8. // Terminate the program with exit() status 0
  9. printf("Terminating the program now...\n");
  10.  
  11. exit(0); // Terminate with status 0 (success)
  12. }
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Current Process ID: 3716827
Terminating the program now...