Typically the assert function is used to validate input arguments passed to a function before using them. In general, input argument checking is enabled in debug builds and disabled in production builds. The assert function validates the expression if it is true. If the expression is false, it invokes abort function to terminate the process.

void assert(scalar expression);

The following example shows how typically assert is used.

void which_fruit(char *name)
{
   assert(name);
   strcpy(name,"apple");
}

In the above example, if a NULL pointer is passed to which_fruit() function, assert evaluates the expression to be false and process gets terminated.

In case of production builds where assert needs to be disabled and termination of the process is not desired, NDEBUG macro should be passed as compilation flag.