C assert function writes error information to stderr and then aborts program
Syntax
C assert
function has the following syntax.
void assert(int exp);
Header file
C assert
function is from the header file assert.h
.
Description
C assert
function writes error information to stderr and then aborts program
execution if the expression exp evaluates to zero.
We can
define NDEBUG
to ignore the assert()
macros.
Example
#include <assert.h>
//from w w w. ja va 2 s. com
int main(void){
assert(1==2);
}
The code above generates the following result.