create loading bar in C++

इस page में एक ही program को different तरीकों से बनाया गया है जहां first program multiple string initialization का एक उदाहरण है।

create loading bar in C++ using array

क्या यह संभव है कि एक single dimensional array में एक से अधिक string को किया जा सके अर्थात ,

char array-variable[size]={"string1","string2","string3"};

सामान्य तौर पर यह संभव नहीं है इसलिए यह ऊपर दिया गया syntax गलत होगा।  इसके लिए हम यहाँ पर एक different keyword को प्रयोग में लाते है इसलिए इसका सही syntax इस प्रकार होगा –

typedef char array-variable[size];
array-variable[] = {"string1","string2","string3"};

सबसे पहले, एक identifier को char data type  का array declared किया जाता हैफिर, उस identifier से string का intialize किया जाता है-

arr[ ] = { " working on it", " "};

याद रहे, हम इसे direct नहीं कर सकते-

char arr[ ] = { "working on it", " "}; // error

लेकिन, two dimensional array में यह possible है, जैसे

char arr[10][20]= { " working on it", " "};

हम नीचे दिए गए कार्यक्रम में single dimentional array का use किया गया है –

#include<iostream.h>
#include<conio.h>  // _setcursortype()
#include<dos.h>  // delay 

void main() 
{ 
   typedef char arr[50];
   arr d[]={"Working on it",""};

//char d[10][20]={"Working on it",""}; // will also work 

   int a,i=0,time=60;
   char c;

   _setcursortype(_NOCURSOR); // disable mouse cursor on monitor screen

   while(i<5) // increase value for more loading 
    { 
      for(int a=0;a<3;a++)
       {
          gotoxy(28,10);
          cout<<d[0]<<" |.... ";
          delay(time);

          gotoxy(28,10);
          cout<<d[0]<<" \\.... ";
          delay(time);

          gotoxy(28,10);
          cout<<d[0]<<" /.... ";
          delay(time); 
      }i++;
    }
 getch();
}

OUTPUT

यहाँ पर अन्य उदाहरण दिए गए हैं।

creating a searching progress bar in c++

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

 void main() 
  {
    char load[]={'|','\\','/'};
    clrscr();
    int second,i=0,time=60;
    char c;

    cout<<"Enter loading time in second:";
    cin>>second;

    _setcursortype(_NOCURSOR);

    while(i<second)
     {
       for(int j=0;j<3;j++)
        {
           gotoxy(28,10);
           cout<<"searching record "<<load[j]<<"....";
           delay(time);
           clrscr();

        } i++;
     }
    getch();
  }

OUTPUT

creating a printing progress bar in C++

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

 void main()
  {
    int pr,dl;
    char load[10][10]={".","..","...","...."};
    pr=0;dl=300;

    _setcursortype(_NOCURSOR);

    while(pr<2)
     {
       for(int i=0;i<4; i++)
        {
          gotoxy(30,10);
          cout<<"Record Printing"<<load[i];delay(dl);
          clrscr();
        }
      pr++;
     }
  }

OUTPUT

we can also make visual bar without using graphics tool, we is the one,

creating a Downloading Progress Bar in C++

#include<iostream.h>
#include<conio.h>
#include<dos.h>
 
 void main()
 {
   int count=2;
   clrscr(); 
   _setcursortype(_NOCURSOR);

   gotoxy(31,10);
   cout<<"File Downloaing..";3
    
   while(count<26)
     {
        gotoxy(25+count,12);
        cprintf("%c",176);
        cout<<count*4<<"%";
        delay(200);3
        if(count==26-1)
          {
             gotoxy(31,10);
             cout<<"Download Complete!";
          }
    count++;
   }
  getch();
 }

OUTPUT

The meaning of giving creates a loading bar in C++ here is to tell only the control statements importance, we can make whatever we want from the control-statement.


Creating a Loading Bar in C++
Creating Searching Progress Bar in C++
Creating Printing Progress Bar in C++
Creating Downloading Progress Bar in C++
Creating a Timer using in C++
Sorting Array Elements as Ascending and Descending Order in C++
Searching Element in Array List in C++
Class with Multidimensional Array in C++
Convert digit values into Character in C++

Leave a Reply

Your email address will not be published.