Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Percent bar or progress report 1

Status
Not open for further replies.

fabien

Technical User
Sep 25, 2001
299
AU
Hi!

I would like to add a percent bar when reading large files. Something like

0% xxxxxxx||||||||| 100%
50% complete

Is it possible?

Many thanks!
 
Which bit are you having trouble with?

Drawing the percentage bar?
Figuring out when you've read the next 1% of the file?


--
 
My problem is to be able to draw the bar on top of the previous one, i.e., make the cursor come back to the begining of the line.

Thanks,
 
Code:
#include <stdio.h>
int main()
{
  int i;
  printf("Hello, World!\n");
  for ( i = 0 ; i < 10 ; i++ ) {
    printf("Now %02d\r", i );
    fflush( stdout );
    Sleep(1000);  // Windows specific delay
  }
  return 0;
}
The "\r" returns to the start of the current line, and the fflush(stdout) ensures your text can be seen.
The delay of course is your extended file reading code.


--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top