I'm trying to run my first "process" program,but but I get the following error :
./fork.c: line 4: syntax error near unexpected token `('
./fork.c: line 4: `int main()'
I'm pretty sure that the code is correct:
#include <sys/types.h>
#include <stdio.h>
int main()
{
pid_t pid;
printf("Hello fork()\n");
switch(pid=fork())
{
case -1: printf("Error by fork().....\n"); exit(0);
case case 0: printf("I'm the child process \n"); break;
default: printf("I'm the dad \n"); break;
}
exit(0);
}
What is wrong?