Can someone help this simple program to prompt the users for a command?
#include "unistd.h"
#include "stdio.h"
int main(){
char command[80];
while (putchar('#'), gets(command)) {
if (fork()){
wait(0); /* Parent */
}
else { /* Child */
execlp(command, command, 0);
printf("command not found\n");
exit(1);
}
}
}
Command given: gcc system.c -o system.exe
Error as followed:
system.c: In function ‘main’:
system.c:12:7: warning: missing sentinel in function call [-Wformat]
system.c:14:7: warning: incompatible implicit declaration of built-in function ‘exit’ [enabled by default]
Have you tried including unistd.h & stdio.h ?
Oh and by the way, from the manual of gets() :