I was taking a look at the assert() reference page and I got stuck while I read the given example:
/* assert example */
#include
#include <
Minor notification: it would be better if you write..
FILE * datafile = NULL;
Also, assert only works in debug mode... so your method is better.
You're perfectly right sir. This is a poor usage of assert
.
You are right indeed. As other people have already pointed out, assert()
will be more than likely compiled out in the release build (I've seen people force the asserts to be left in for the release build).
I just wanted to add a horror story related to this question that I've seen on a code-base:
assert(do_something() == NO_ERR);
Some people should not be allowed to use a keyboard.