In the following program I commented the statement #include <ctype.h> in the hope that an error will be thrown while using the functions like isupper and isgraph. But to my surprise no error is thrown. Why is this so ? The wikipedia page lists these functions in the header type ctype.h.
#include <stdio.h>
//#include <ctype.h>
int main() {
char ch;
for(;;) {
ch = getc(stdin);
if( ch == '.') break;
int g = isgraph(ch);
if(isupper(ch) != 0) printf("Is in upper case\n");
}
return 0;
}
Note: I am using gcc to compile on linux (fedora).
By default,
gccruns in a rather permissive mode. You can get a warning by adding, for example:asking for all the main warnings. (There are more warnings you can asl for:
-Wextraadds a bunch.) You might also specify-std=c99(and maybe-pedantic) in order to get more warnings.C99 requires functions to be defined or declared before they are used.
That’s the output of GCC 4.7.1 (on Mac OS X 10.7.5) with the standard set of compilation options I use — run on your source code stashed in a file
warn.c.