I have a slow running loop that can take an hour or more so I want to print a progress indicator. I'm using the following kind of code.
for (int i=0; i<=j; i++)
{
pass[0] = 'A' + i;
printf("%c", pass[0]);
\\Some slow running code omitted for brevity
}
If I use this code it will spit out ABCD...Z (or stop when it finds the answer) when then entire loop completes which defeats the purpose of having a progress indicator. But if I include a new line character \n in the printf statement, it will print ABCD out progressively while the loop is running. That is the behavior I want but unfortunately it adds a line break between each letter.
I tried to add a space and that didn't work because it won't print until the entire loop is done. I even tried using the putchar() function and that behaved the same as the printf() function where I cannot get it to progressively print out the letters unless I insert a new line between each character. Can anyone explain this behavior or what I'm doing wrong?