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

  • Stop wasting time looking for files and revisions! Dokkio, a new product from the PBworks team, integrates and organizes your Drive, Dropbox, Box, Slack and Gmail files. Sign up for free.

View
 

Assert

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