errono should always be checked after calling any function in which it might be set.
errono should always be checked after calling any function in which it might be set.
# include <errno> // include errno definition ...double x = ...;errno = 0; // clear out error flagdouble d = sqrt(x);if (errno == EDOM) // test global status flag ... // handle error case
// is sqrt evaluated first, or g?double d = sqrt(x) * g(); // worse, what happens if g clears // a flag that was set by sqrt ?double g () { errno = 0; return 3.14159 * sin(42);}