I have problem with this code. When I gonna run it it'll show me "No File"
#include <string.h>
#include <stdio.h>
main (argc, argv)
char *argv[];
{
int fd;
extern int errno;
if (argc < 2) {
fprintf (stderr, "No file\n");
exit(1);
}
if ((fd = creat(argv[1], 0777))< 0){
fprintf(stderr,"Cannot create file %s\n", argv[1]);
exit(1);
}
switch (fork()) {
case -1:
fprintf(stderr, "Fork error\n");
exit(1);
case 0:
close(1);
dup(fd);
close(fd);
execl("/bin/ls", "ls", NULL);
perror("Exec");
break;
default:
wait(0);
close(fd);
}
exit(0);
}
and will put out "warning: incompatible implicit declaration of built-in function 'exit'" - for all 5 exit.