#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
#define MAXB 255
int main(void)
{
char buf[MAXB];
int status;
while(1)
{
printf("%% ");
scanf("%s",buf);
buf[strlen(buf)]=0;
if(!strcmp(buf,"exit")
{
printf("\nTerminated by user\n");
exit(0);
}
if(fork()==0) execlp(buf,buf,NULL);
wait(&status);
printf("Exit status: %d\n",status);
}
return 0;
}
Pomoże ktoś naprawić błąd ?
prog.c: In function ‘main’:
prog.c warning: implicit declaration of function ‘strlen’
prog.c warning: incompatible implicit declaration of built-in function ‘strlen’
prog.c warning: implicit declaration of function ‘strcmp’
prog.c error: expected ‘)’ before ‘{’ token
prog.c error: expected expression before ‘}’ token