5.2. The assert() macro

The assert() macro allows us to test that data passed to a function satisfies certain criteria for which the function returns valid data as the calling function might expect.

#include <assert.h>

assert( logical expression );

If the logical expression passed to the assert macro is false, then an error message is printed and the program exits.

#include <assert.h>

int testfunction( int a )
{
   int b;
   assert( a >= 0 );
   .
   .
   .
   assert( b >= 1 );
   return( b );
}