Name: Anonymous 2013-10-20 22:56
Post a random function that you made. May be from any project you've done or make one impromptu.
Any QUALITY is allowed. No bullying!
Any QUALITY is allowed. No bullying!
while((c = fgetc(f)) != EOF)in a system where char is unsigned and sizeof (char) == sizeof (int) EOF is a vaild character
while((c = fgetc (f)) != EOF || (!feof (f) && !ferror (f))
exit (1);you cause a implemented defined behavior by returning 1, the standard values are 0, EXIT_SUCCESS, EXIT_FAILURE
fprintf(stderr, "\n");since \n is a single character I would use
fputc ('\n', stderr);
but this is not really a problemvoid *you don't return something from that function, you should retrun void and in C11 you can add _Noreturn with the void
(f = fopen(*++argv, "r")) || error("fopen", "Couldn't open %s", *argv);what if *++argv == NULL? undefined behavior. you must check it. I would use
if (argv[0] && argv[1]) (f = fopen (argv[1], "r")) || error ("fopen", "Couldn't open %s", argv[1]);