problem with cc
I get the following error messages when i execute this c program.
#include<
#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
int main()
{
pid_t childpid;
int status,wait_val;
if((childpid=
{
perror("The fork failed");
exit(1);
}
else if(childpid==0)
{
printf("This i schild with id : %d\n",getpid());
printf("The parent id= %d\n",getppid());
exit(2);
}
else
{
wait_val=
printf("Return Value of wait system call : %d\n",wait_val);
printf("This is parent with pid = %d\n",getpid());
printf("The is child with pid = %d\n",childpid);
}
exit(0);
}
avinash@
prog10b.c:1:22: error: sys/types.h: No such file or directory
prog10b.c:2:18: error: stdio.h: No such file or directory
prog10b.c:3:19: error: unistd.h: No such file or directory
prog10b.c:4:19: error: stdlib.h: No such file or directory
prog10b.c: In function ‘main’:
prog10b.c:8: error: ‘pid_t’ undeclared (first use in this function)
prog10b.c:8: error: (Each undeclared identifier is reported only once
prog10b.c:8: error: for each function it appears in.)
prog10b.c:8: error: expected ‘;’ before ‘childpid’
prog10b.c:10: error: ‘childpid’ undeclared (first use in this function)
prog10b.c:13: warning: incompatible implicit declaration of built-in function ‘exit’
prog10b.c:17: warning: incompatible implicit declaration of built-in function ‘printf’
prog10b.c:19: warning: incompatible implicit declaration of built-in function ‘exit’
prog10b.c:24: warning: incompatible implicit declaration of built-in function ‘printf’
prog10b.c:28: warning: incompatible implicit declaration of built-in function ‘exit’
PLS HELP.
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- Ubuntu Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Gord Allott
- Solved:
- Last query:
- Last reply: