ADVERTISEMENT
ADVERTISEMENT

Home » C programs » graphics.h header file functions

C program to create progress bar using graphics.h

In this article, we are going to learn about how to create a process bar in C graphics in C programming language?
Submitted by Ashish Varshney, on March 18, 2018

This is how program’s output looks like...

How to create progress bar in C

Creating process bar with graphics.h is fairly easy. What it takes is to initialize a graph with two parameters and a path to the "bgi" folder in your system.

For initialize the graphics we use: initgraph(&gd,&gm,"C:\\TURBOC3\\BGI");

initgraph() function is a function of graphics.h header file.

After that, we will call the function called settextstyle() with 3 parameters(font-family, direction, stroked size) then we call outtextxy() with 3 parameters(x-coordinate, y-coordinate, string), then a for loop to produces process bar from x1 to x2 coordinates with height h.

Program to create progress bar in C



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

int main()
{
	inti,gd=DETECT,gm;
	initgraph(&gd,&gm,"C:\\TURBOC3\\BGI");
	
	settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
	outtextxy(177,180,"Loading, Please Wait...");
	
	for(i=190;i<510;i++)
	{
		delay(30);
		line(i,210,i,230);
	}
		
	closegraph();
	getch();
	
	return 0;
}
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.