On Fri, 29 Jan 2021, Chuck Guzis via cctalk wrote:
In the past (and occasionally today, I use the
if ( !(myfile = fopen( filename, "r"))
fprintf( stderr, "Couldn\'t open %s - exiting\n", filename);
Yes, it only saves a line, but neatly describes what's being done.
That is another excellent example of where you DO want to do an assignment
AND a comparison (to zero). A better example than my strcpy one, although
yours does not need to save that extra line, but a string copy can't
afford to be slowed down even a little.
That is why it MUST be a WARNING, not an ERROR.
Of course, the error is when that wasn't what you intended to do.