assert()

It it defined in <assert.h> as

  1. #include<assert.h>
  2. void assert(int expression)

if expression is false, it print an error message to stderr and stop the program by calling abort. See example as below.

#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
int main( void )
{
       FILE *fp;
       cout << "testing asset" << endl;
       assert(true);    // true program pass here and below printed
       cout << "testing asset true" << endl;
       assert(false);   // false. Abort raised and program stopped here
       cout << "testing asset false" << endl;    //never reached here and below

       return 0;
}