Tuesday, 10 January 2012

Create Graphical Loading Bar in C



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

void main(void)
{
int driver=DETECT, mode;


        int i;

         initgraph(&driver,&mode,"c:\\tc\\bgi");   //initialize graphics mode
textcolor(BLACK);      //background color

        moveto(200,180);        //loading process
outtext("Loading, please wait...");
   for(i=0;i<600;i+=15)
   {
    setcolor(3);            //loading bar color
    line(20,380,i+39,380);
    delay(150);         //slow down loop speed
   }
setcolor(WHITE);
moveto(210,200);
outtext("Loading Completed!");   //loading process complete
delay(1000);
       closegraph();               //close graphics mode


}




If you have any problem with the above code, you can contact me...

5 comments:

hariiii said...

i am getting a linker error...how to remove it

MuzammilVersiani said...

@hariiii, Can you post the error and your code here so that I can see what is exactly happening ????

Palash Bansal said...

You may have to install turbo c++ again to get rid of the linker error.

Unknown said...

when I run the Program then complier show me 2 errors
The errors are Function 'intigraph' should Have a prototype
and the other error is Function 'deley' should Have a prototype.

MuzammilVersiani said...

@Mangal Singh are you sure you are using 'initgraph' and not 'intigraph'?

Post a Comment