assert.h header file in C Programming

assert.h is a header file which defines C preprocessor macro as assert(). Macro uses assertion which is used to verify conditions or assumptions in a program. It prints message when it returns false.
The use of assert() can be defined as follow :

Program :

/*  Program to demonstrate assert.h header file working.
Creation Date : 06 Nov 2010 04:02:21 PM
Author : www.technoexam.com [Technowell, Sangli] */

#include <stdio.h>
#include <conio.h>
#include <assert.h>

int main(void)
{
	clrscr();
	assert(12 == 2);
	getch();
	return 0;
}

Output :

Assertion failed: 12==2, file ..\ASSERT.C, line 5
Abnormal program termination
_

Leave A Comment

Your email address will not be published. Required fields are marked *