![]() |
| | #1 |
| Registered User Join Date: Aug 2009
Posts: 2
| printf refresh screen Code: #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define COUNT 20000000
int main()
{
int x;
char ak[2];
char pb[] = " "; //this is a long blank string
system("clear");
printf("Calculating some immensly important calculation.\n");
// |= = = = = = = = = =| progress bar will look like this
printf("| | 0% complete.");
for (x=1;x<11;x++)
{
delay();
pb[(x-1)*2]='=';
printf("\r"); //return to beginning of line
printf("|%s| %d%% complete.",pb,x*10);
}
printf("\n\nPress Enter to exit.");
gets(ak);
system("clear");
return (0);
}
delay() //this function is simply a delay.
{
int tv;
double zxc;
for(tv=0;tv<COUNT;tv++)
zxc=sqrt(tv+5);
}
|
| nelsonhoover is offline | |
| | #2 |
| Registered User Join Date: Sep 2004 Location: California
Posts: 2,845
| You can try using fflush(stdout) to ensure that the output buffer is flushed to the screen.
__________________ bit∙hub [bit-huhb] n. A source and destination for information. |
| bithub is offline | |
| | #3 |
| subminimalist Join Date: Jul 2008 Location: NYC
Posts: 3,944
| Use fflush(stdout): Code: printf("hello world\n"); fflush(stdout);
__________________ Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS |
| MK27 is offline | |
| | #4 |
| Registered User Join Date: Aug 2009
Posts: 2
| It worked Thanks, that did the trick quite nicely. Thanks for your help. |
| nelsonhoover is offline | |
![]() |
| Tags |
| printf, refresh screen |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problems reading entered race times C | loopymoo26 | C Programming | 12 | 05-23-2009 07:38 AM |
| My calculation, delete and update functions dont work (Programming language C) | TKaeWoods | C Programming | 2 | 03-05-2009 10:25 AM |
| get keyboard and mouse events | ratte | Linux Programming | 10 | 11-17-2007 05:42 PM |
| I need help on this particular Linked List problem | sangken | C Programming | 11 | 08-06-2006 12:26 AM |
| whats wrong with this? | petedee | C Programming | 32 | 01-06-2004 10:28 PM |