C++ program to create a loading bar

C++ program to create a loading bar

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

void main()
{
int x=170,i,gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,”c:\tc\bgi”);
settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
outtextxy(170,180,”LOADING,PLEASE WAIT”);

for(i=0;i<300;++i)
{
delay(30);
line(x,200,x,220);
x++;
}
getch();
closegraph();
}

34 thoughts on “C++ program to create a loading bar”

    1. There is no need to learn OpenGL ..
      because….the problem is with your code
      try this-

      initgraph(&gdriver,&gmode,"_____");

      just put the path to BGI folder in place of _____
      or if you have Turbo c++ by Neutron then you can use this –

      initgraph(&gd,&gm,"C:\Turboc3\BGI");

      this will help you

        1. Go to your Turbo c++ folder in C:/ directory. Then go to Disk>TurboC3>BGI. Sorry for the late comment. I have posed the solution way back in 2014. Hope it still helps šŸ™‚

  1. Negulet Mircea Eduard

    In function initgraph(&gdriver,&gmode,"c:tcbgi"); , you have the path for graphic driver <"c:tcbgi">. Correct the graphic driver.

      1. This is my code… which I am running..

        #include
        #include
        #include
        #include

        void main()
        {
        int x=170,i,gdriver=DETECT,gmode;
        initgraph(&gdriver,&gmode,”C:\TURBOC3\BGI”);
        settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
        outtextxy(170,180,”LOADING,PLEASE WAIT”);

        for(i=0;i<300;++i)
        {
        delay(30);
        line(x,200,x,220);
        x++;
        }
        getch();
        closegraph();
        }

        Error: BGI ERROR : graphics not initialized (use initgraph)
        P.s. My BGI location is correct.

  2. its not running
    ill try to run it but it will not go to the output but it doesnt said that i have any errors what should i do

  3. Help… Ive messed up somewhere and can’t get up

    IDE:
    Borland C++ 5.02 fresh install

    code:
    #include
    #include
    #include
    #include

    void main()
    {
    int x=170,i,gdriver=DETECT,gmode;
    initgraph(&gdriver,&gmode,ā€c:\bc5\bgiā€);
    settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
    outtextxy(170,180,ā€LOADING,PLEASE WAITā€);
    for(i=0;i<300;++i)
    {
    delay(30);
    line(x,200,x,220);
    x++;
    }
    getch();
    closegraph();
    }

    message:
    Transferring to C:\bc5\bin\tlink.exe @c:\bc5\bin\proj0001.r$p

    ! (1, 1): Undefined symbol _closegraph in moule proj0001.cpp
    ! (1, 1): Undefined symbol _line in moule proj0001.cpp
    ! (1, 1): Undefined symbol _outtextxy in moule proj0001.cpp
    ! (1, 1): Undefined symbol _settextsyle in moule proj0001.cpp
    ! (1, 1): Undefined symbol initgraph in moule proj0001.cpp

  4. EVERYBODY MUST BE AWARE THAT THIS EXAMPLE IS FOR TURBO/BORLAND C++ (till version 3.1 only). ANY OTHER C++ (Visual C++ OR C++ Builder) ARE NOT GOING TO WORK.

  5. #include
    using namespace std;
    int main()
    {
    char x=219;/*ASCII value for block*/
    int i=0,j=0,k=0,l=0,m=0;
    cout<<" ______________________________________\n";
    cout<<"Loading data ";
    while(i<100000)
    i–;
    cout<<x<<x<<x<<x;
    while(j<0)
    j–;
    cout<<x<<x<<x<<x;
    while(k<100000000)
    k–;
    cout<<x<<x;
    while(l=0)
    l–;
    cout<<x<<x<<x<<x<<x<<x<<x<<x;
    while(m<100000)
    m–;
    cout<<x<<x<<x<<x;
    while(m<1000)
    m–;
    cout<<x<<x<<x<<x<<x<<x;
    while(l=0)
    l–;
    cout<<x<<x<<x<<x<<x<<x<<x<<x<<x<<x<<"\n\n";
    return 0;
    }

Leave a Comment

Your email address will not be published. Required fields are marked *