Skip to main content
Tweeted twitter.com/#!/StackUnix/status/234844775587659778
added 51 characters in body; edited tags; edited title
Source Link
Renan
  • 17.2k
  • 8
  • 72
  • 91

running my first fork Why can't I run this C program :(?

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?

running my first fork program :(

I'm trying to run my first "process" program,but 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  0: printf("I'm the child process \n"); break;
default: printf("I'm the dad \n"); break;
}
  exit(0);
}

Why can't I run this C program?

I'm trying to run my first "process" program, 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 0: printf("I'm the child process \n"); break;
         default: printf("I'm the dad \n"); break;
     }
  exit(0);
}

What is wrong?

Source Link
Engine
  • 261
  • 2
  • 5

running my first fork program :(

I'm trying to run my first "process" program,but 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  0: printf("I'm the child process \n"); break;
default: printf("I'm the dad \n"); break;
}
  exit(0);
}