Home » C programs » graphics.h header file functions

cleardevice() function of graphics.h in C

In this article, we are going to learn about the use of cleardevice() function of graphics.h header file in C programming language and try to clear the device screen using it after printing the message for user.
Submitted by Manu Jemini, on March 24, 2018

Clearing the screen is always an issue for developers, because now and then we want to show the user some useful or important data, which should be highlighted or at least have user’s attention.

To clear the console window or we can say the graph itself, just call the function cleardevice() and it will clear the screen.

It is important to note that, after clearing the device, we will lose all our drawing, shapes or images. It is useful but be little cautious.


graphics.h - cleardevice() function in C

#include <graphics.h>
#include <conio.h>

int main() 
	//initilizing graphic driver and 
	//graphic mode variable
	int graphicdriver=DETECT,graphicmode;

	//calling initgraph

	//Printing message for user
	outtextxy(20, 20 + 20, "Program to use graph default in C graphics");

	//message to clear screen
	outtextxy(20, 50 + 30, "Press any key to clear screen");

	//getting character and clear the device screen

	//message to press key to get exit from program
	outtextxy(20, 20 + 20, "Press any key to exit...");

	return 0;


cleardevice() function of graphics.h in C 1
cleardevice() function of graphics.h in C 2



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

© some rights reserved.