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

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

Assert

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