| 
  • Earn a $50 Amazon gift card for testing a new product from the makers of PBworks. Click here to apply.

  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

View
 

Assert

Page history last edited by Kenneth Finnegan 11 years, 9 months ago

Assert is a standard library function.  If the value you pass it is or evaluates to zero, assert will print which line in which file the assert failed and will exit the program.

 

Code:

 

#include <assert.h>

 

Usage:

// Is this pointer NULL?

assert(pointervar);

// Is the int initialized to zero?

assert(varname == 0);

// Is this number odd?

assert(varname%2);

 


Extensions:

None known.


Sources:

The C Programming Language 2nd Ed., Kernighan & Ritchie, pp. 253

Comments (0)

You don't have permission to comment on this page.