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

  • Files spread between Dropbox, Google Drive, Gmail, Slack, and more? Dokkio, a new product from the PBworks team, integrates and organizes them for you. Try it for free today.

View
 

Assert

Page history last edited by Kenneth Finnegan 11 years, 11 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.