Reference · Data types · assert.h Standard C · assert.h · complex.h · ctype.h · fenv.h · float.h · locale.h · math.h · setjmp.h · signal.h · stdarg.h · stddef.h · stdlib.h · stdio.h · string.h · time.h Standard C++ · IOstream Win32 · gc.h DOS, DOS32, Win16 · bios.h · cerror.h · disp.h · dos.h · dos.h part 2 · emm.h · handle.h · int.h · msmouse.h · sound.h · swap.h · tsr.h · winio.h Other C · bitops.h · conio.h · controlc.h · direct.h · fltpnt.h · io.h · page.h · process.h · search.h · sys\stat.h · tabsize.h · trace.h · utime.h · unmangle.h · util.h Other C++ · regexp.h · class complex |
assert.hPrototypevoid assert(expression); Description This function is useful for adding internal consistency checks. When assert is executed it checks the expression argument and, if it is zero, displays the following message on the standard error device, after which the program aborts. Assertion failure: 'expression' on line ?? in file '??? ' The assert function can be deactivated by defining the macro NDEBUG prior to the inclusion of assert.h header file. The effect is that all assertions become null statements. Return Value None Compatibility DOS Windows 3.x Phar Lap DOSX Win32 Example /* Example of assert */ #include <assert.h> #include <stdio.h> #include <stdlib.h> void main() { int value; value = 3; while (value) { assert (value > 1); printf (" Passed assert (%d > 1)\n", value); value--; } }Output
Passed assert(3 > 1) |