assert. McGraw-Hill The Complete Reference Fourth Edition
जाहिरात
जाहिरात
C h a p t e r 3 0 : U t i l i t y F u n c t i o n s
763
The abs( ) function returns the absolute value of num. The long version of abs( ) is the same as labs( ). The double version of abs( ) is the same as fabs( ).
A related function is labs( ).
assert
#include <cassert> void assert(int exp);
The assert( ) macro, defined in its header <cassert>, writes error information to
stderr
and then aborts program execution if the expression exp evaluates to zero.
Otherwise, assert( ) does nothing. Although the exact output is implementation defined, many compilers use a message similar to this:
Assertion failed: <expression>, file <file>, line <linenum>
The assert( ) macro is generally used to help verify that a program is operating correctly, with the expression being devised in such a way that it evaluates to true only when no errors have taken place.
It is not necessary to remove the assert( ) statements from the source code once a program is debugged because if the macro NDEBUG is defined (as anything), the
assert( )
macros will be ignored.
A related function is abort( ).
atexit
#include <cstdlib> int atexit(void (* func)(void));
atof
The atexit( ) function causes the function pointed to by func to be called upon normal program termination. The atexit( ) function returns zero if the function is successfully registered as a termination function, nonzero otherwise.
At least 32 termination functions may be established, and they will be called in the reverse order of their establishment.
Related functions are exit( ) and abort( ).
#include <cstdlib> double atof(const char * str);
डाउनलोड
जाहिरात