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().

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



Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.