Hi,
In error checking part of code below (where the existence of file to read is checked), my (hopefully correct) understanding is printf would print to stdout, and the fprintf statement (currently commented out) means that fprintf prints error messages to stderr.
As I see it, both print out the "Unable to open" message so was wondering what the 'stderr' actually means, and which statement (the printf or the fprint) is the preferred choice in this case and why?
Thanks!!
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE *ofPtr;
ofPtr = fopen("oldmast.dat", "r");
if ( ofPtr == NULL )
{
printf ("Unable to open oldmast.dat\n");
// fprintf(stderr, "Unable to open oldmast.dat\n");
exit(0);
}
return 0;
}