Home > Electronics Tutorials > C Language Tutorial > assert.h - assert.h

C Language Programming Library Reference Guide

assert.h - assert.h

The assert header is used for debugging purposes.


assert(); External References: NDEBUG


void assert(int expression); The assert macro allows diagnostic information to be written to the standard error file.

If expression evaluates to 0 (false), then the expression, sourcecode filename, and line number are sent to the standard error, and then calls the abort function. If the identifier NDEBUG ("no debug") is defined with #define NDEBUG then the macro assert does nothing.

Common error outputting is in the form:

Assertion failed: expression, file filename, line line-number Example:

void open_record(char *record_name)
  /* Rest of code */

int main(void)
Note: To report broken links or to submit your projects, tutorials please email to Webmaster