Home » C programs » assert.h header file functions

assert() function of assert.h in C

In this article, we are going to learn about the use assert() function of assert.h header file in C language, and use it to hold the process till 0 passes as a parameter.
Submitted by Manu Jemini, on April 04, 2018

If you are looking for a function which keeps track of a variable’s value. If the value changes, the function tells about it, otherwise not.

Using assert function comes up mainly during testing, when you want to check for all the variables during the program lifecycle. This can also be useful in debugging, if your program got lots of manipulation and you want to check if value of a variable crosses certain limit or even changes.

To make use of assert just call it with the variable of your choice.


    Assert (a)
    This will keep track of value of a.

assert.h - assert() function Example in C

#include <stdio.h>
#include <assert.h>
int main()
	// Defining variables
	int a;
	// Assigning value of a=2
	a = 2;
	// Displaying the value of a
	printf("Value of a is: %d\n", a);
	// assert function will not exit till the value of a =0
	// now change the value of a=0
	a = 0;
	// Displaying the value of a
	printf("Value of a is: %d\n\n", a);
	// again calling the function with different parameter
	return 0;


assert.h - assert()  in c language

Was this page helpful? Please share with your friends...

Are you a blogger? Join our Blogging forum.

Comments and Discussions

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com (2015-2018), Some rights reserved.

close Like other websites, this site uses cookies to deliver relevant ads based on your interest, by using our website, you acknowledge that you have read our privacy policy.