J
James Kanze
On 2007-04-08 19:08, David Harmon wrote:
That's C and would work if "inFile.open("people.dat");" had set errno,
but it does not.
It does, since it is defined in terms of fopen. How, of course,
or whether the error message is in any way appropriate to the
situation, is implementation defined. And of course, for
whatever reasons, the original poster apparently wanted the
error message on standard out, rather than standard error;
perror doesn't offer such a chose. (Most of my own work is on
servers, where both standard out and standard error are
connected to /dev/nul. So I'll generally output to a log file
or generate an email. I don't know why he assumes that everyone
would want to output to standard error.)
I also generally use a global class for such error messages,
which memorizes the fact that the error has occured, and
reflects it in the program return code.