Thread: Loading Bar
View Single Post
Old 07-21-2005, 06:10 AM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,712
redhead is on a distinguished road
Hmm.. didn't my latest display of such a solution give you any idear ??
The theory in it, is to dislay the percentage as beeing:
(<amount done>*100)/<total amount>
The question on how to be certain how much the total amount is, thats a good one, if it's reading from a file you could probably find a clever way of guessing it from some combination of tellg() and seekg(). Something which theoreticaly might sound like:
Code:
1) open file
2) start = tellg()
3) seekg(0, ois::end)
4) end = tellg()
5) seekg(0, ios::beg)
6) while(!eof)
        read input from file
        cur = tellg();
        percent = ((cur - start)*100/(end - start)); 
        display_percentage(percent);
         do stuff with input
7) close file.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote