Program #29
Description:
Draw Progress Bar using C Program. ASCII character plays to vital role to make it.
ASCII Positions of { 176, 177, 178 and 220} are good to make Progress Bar.
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
/* Define default postion to
Row, Column, Progress bar length and ASCII Position used to make progress Bar
*/
#define DEFAULT_COL 25;
#define DEFAULT_ROW 12;
#define BLOCKS_TO_PRINT 25;
#define ASCII_POSITION 220;
/* !Important:
Character Position 176, 177, 178 and 220
are good to make Progress Bar */
void main() {
int i, col, row, blocks;
char myAscii;
/* prototype declaration */
char getAscii();
/* Clear the Screen */
clrscr();
/* Set default position to print */
col = DEFAULT_COL;
row = DEFAULT_ROW;
blocks = BLOCKS_TO_PRINT;
/* get expected ASCII */
myAscii = getAscii();
for(i=1;i<blocks;i++) {
gotoxy(col++, row);
printf("%c", myAscii);
delay(50);
}
getch();
}
/* Iterate the loop until expected ASCII character */
char getAscii(){
int i, ascii_pos;
char cc;
/* Assign default character position */
ascii_pos = ASCII_POSITION;
for (i=0; i<256; i++) {
/* Break the Loop, once we got the Character */
if (i == ascii_pos) break;
cc = cc + 1;
}
return cc;
}
Description:
Draw Progress Bar using C Program. ASCII character plays to vital role to make it.
ASCII Positions of { 176, 177, 178 and 220} are good to make Progress Bar.
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
/* Define default postion to
Row, Column, Progress bar length and ASCII Position used to make progress Bar
*/
#define DEFAULT_COL 25;
#define DEFAULT_ROW 12;
#define BLOCKS_TO_PRINT 25;
#define ASCII_POSITION 220;
/* !Important:
Character Position 176, 177, 178 and 220
are good to make Progress Bar */
void main() {
int i, col, row, blocks;
char myAscii;
/* prototype declaration */
char getAscii();
/* Clear the Screen */
clrscr();
/* Set default position to print */
col = DEFAULT_COL;
row = DEFAULT_ROW;
blocks = BLOCKS_TO_PRINT;
/* get expected ASCII */
myAscii = getAscii();
for(i=1;i<blocks;i++) {
gotoxy(col++, row);
printf("%c", myAscii);
delay(50);
}
getch();
}
/* Iterate the loop until expected ASCII character */
char getAscii(){
int i, ascii_pos;
char cc;
/* Assign default character position */
ascii_pos = ASCII_POSITION;
for (i=0; i<256; i++) {
/* Break the Loop, once we got the Character */
if (i == ascii_pos) break;
cc = cc + 1;
}
return cc;
}