Originally Posted by
munna_dude
hi
assuming that .i am copying only one file.
it may be the size of 1k,10k,99k,1M,999M and 3G
how can i derive the pulses of progressbar?.
and what is 100/n?
i am storing the size in "char".
how can i divide this..
please help me
thank you in advance
I would change your size variable to something much larger than a char. I'm thinking your OS will have a default variable type for use with file sizes, and your compiler will support that type, also.
The 100/n refers to how often you might want your progress bar to show progress, as the file (or files) is (are) being moved, I believe. I think of it as 1/100th or 1%.
In your copy loop:
pseudo code:
Code:
i = 0
while there are more bytes to be copied
i += 10
fgets() or fread() say 512 bytes, if available
and write it to the new file
fprintf() or fwrite()
if( bytes copied * 100 > i * total bytes to be copied)
print another progress char (ASCII char 176, 177, 178 in text mode, recommended).
loop back
It looks nice if the progress bar has at least 10 char's in it's width, and no more than 30.