Hey guys. So I have been learning C for a couple weeks now, and I ran into something I can't quite figure out. I am using gcc 4.6.1 on Linux to compile my programs. I have also been using the -Wall flag. This program is very basic and rudimentary, I know that, I am just learning about file i/o so I just wrote this to test.
So, in this program, running on Linux, the sleep() command will tell the terminal to sleep with the argument in seconds (4). When I compile without the -Wall flag, it compiles, runs, etc just fine. However, when I use the -Wall flag, I get
printf("File could not be created\nPlease create the file then restart program");
printf("Enter your first and last name\n:");
scanf("%s%s", fname, lname);
fprintf(write, "%s\t%s", fname, lname);
printf("Now I will try and open the file and read the name you entered\n");
printf("The file could not be opned\n");
fscanf(read, "%s%s", fname, lname);
printf("\nYou entered\n\n:%s %s\n\n", fname, lname);
The code is still compiled, and produces the executable, but I get the compiler warnings.
$ gcc -Wall files.c -o filetest1
files.c: In function ‘main’:
files.c:29:5: warning: implicit declaration of function ‘sleep’ [-Wimplicit-function-declaration]
The same thing happens when I use something like getchar() or the like. Is there something I can do to get rid of these warnings?
Thanks for your help.