M
Michel Rouzic
With the following code :
int main()
{
int i, j, n;
n=12;
for (i=0; i<n; i++)
{
printf("Iteration %i out of %i\n", i+1, n);
for (j=0; j<100000000; j++) {}
}
return 0;
}
With \n at the end of the line to be printed, everything will printf
when it should
With \r intead of \n, or just no \n or \r, nothing will get displayed
before the loop ends (it will print it all at once, or if there's a \r,
only the last remaining line)
Does anyone know the origin of this somewhat weird behavior, and does
anyone know how to fix it so I can display the progress of my
iterations on only one line (by using \r at the end) ?
int main()
{
int i, j, n;
n=12;
for (i=0; i<n; i++)
{
printf("Iteration %i out of %i\n", i+1, n);
for (j=0; j<100000000; j++) {}
}
return 0;
}
With \n at the end of the line to be printed, everything will printf
when it should
With \r intead of \n, or just no \n or \r, nothing will get displayed
before the loop ends (it will print it all at once, or if there's a \r,
only the last remaining line)
Does anyone know the origin of this somewhat weird behavior, and does
anyone know how to fix it so I can display the progress of my
iterations on only one line (by using \r at the end) ?