I got nothing on what you wrote.
typically a progress bar divides the amount of work being done (eg, % of a file read in bytes by size, or # of lines, etc) and 'draws' (can be ascii art) the bar filled to that percent until done. Some text codes just display the numerical % instead. Since you use getch, you may also use gotoxy to over-write so the bar changes in place rather than redrawn line by line in the console.
so say your progress bar is drawn with 20 '-' characters, maybe '_' or spaces for the empty part.
that is 5% per tick. So if you were processing a file with 300 lines... every 15th line you add a tick to your bar, because 15*1, 15*2 (30)... 15*20 = 300. If it does not work out evenly, you can fudge the last tick a little and just wait for true 100% to fill it in, or something like that.
so basically, yes a loop... loop over the thing you are processing, and every so many loop iterations, you update your progress bar.
something like
1 2 3 4 5 6 7
|
mypbar.init(somevalue); //some sort of setup to tell it what 100% means.
for(int i = 0; i < somevalue; i++)
{
if(i%something == 0) mypbar.update(i); //or however you have your progress
// bars defined here. I assume long term, an object with a method.
}
mybar.update(somevalue); //you may need one more call to have it hit 100% here
|