Pages

Wednesday, October 7, 2009

A 'C' Program for how to implement Progress Bar (.c file)

#include"stdio.h"
#include"conio.h"                                                                                     
#include"dos.h"
void main()
{
    int m,kbhit(void);
    clrscr();
    while(!kbhit())
    {
        printf("\b\\");
        delay(100);    /* Delay is defined in Dos.h */
        printf("\b|");  
        delay(100);  /* U might not have this if u use Borland C */
        printf("\b/");
        delay(100);
        printf("\b-");
        delay(100);
    }
return;     /* Keep the compiler happy */
}

void rotate(void)
{
    static short index=0;
    printf(" ");
    switch(index)
    {
        case 0 : printf("\b\\");
            index++;
            break;
        case 1 : printf("\b|");
            index++;
            break;
        case 2 : printf("\b/");
            index++;
            break;
        case 3 : printf("\b-");
            index = 0;
            break;
    }
}

void rotate(void);
while ( /* Some Expresseion */ )
{
      /* Body of loop */
      rotate();
}

 

No comments:

Post a Comment