| 
  • 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. Connect your Gmail, DriveDropbox, and Slack accounts and in less than 2 minutes, Dokkio will automatically organize all your file attachments. Learn more and claim your free account.

View
 

Assert

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