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;
}



Comments and Discussions!

Load comments ↻





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