ADVERTISEMENT
ADVERTISEMENT

Home » C programs » graphics.h header file functions

graphdefaults() function in graphics.h in C

In this article, we are going to learn about the use of graphdefaults() function of graphics.h header file in C programming language, and try to use it by the help of an example.
Submitted by Manu Jemini, on March 24, 2018

Having a nice background color of the screen can do significant things to your application. Black Color is a default for the console window. But you can easily change the color of the console window.

To change the color of the console window all you need to do is to call a setbkcolor() function, with a parameter of the name of the color, like BLUE, GREEN etc. This function will change the color instantly and the background color will change.

There is another function which sets the color to default. The function is useful because it’s fast. It also sets some other properties to default too. Simple call that function like this: graphdefaults().

ADVERTISEMENT

graphics.h - graphdefaults() function in C



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

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

	//calling initgraph
	initgraph(&graphicdriver,&graphicmode,"c:\\turboc3\\bgi");

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

	//setting color and background color
	setcolor(GREEN);

	setbkcolor(BLUE);

	//creating circle
	circle(250, 250, 50);

	//hold screen until getting character

	getch();

	graphdefaults();

	getch();

	return 0;
}

Output

graphdefaults() function in graphics.h in C 1
graphdefaults() function in graphics.h in C 2

ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

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 some rights reserved.