Show progress in console application

Hi all
I have a program in C++ that I compiled on Ubuntu 9.0 and Centos 5, after I got it running on Windows. In this program, I show progress of a process using the following construct:

i = 0;
quantum = floor(total_iterations, 100);
perc = 0;
do
{
  remain = fmod(i, quantum);
  if(remain == 0)
  {
     printf("%d percent complete\r", perc);
     perc++;
  }
  i++;
}while(condition);

The progress shows correctly on Windows, i.e., I see "1 percent complete", then "2 percent complete" and so on. However, when I run the program on *nix, the progress does not show. All I see is the final "100 percent compelte"
I can't figure out why this would be the case. Any clue?

First, that code is C, not C++.
Second, output on most UNIX terminals is line buffered, which means that a line won't be printed until it's ended ith a newline. You can use either man fflush (POSIX) after each line or man setvbuf (POSIX) on stdout to force output.

Awesome! Thanks pludi. I think that is what would work. I'll try it out as soon as my current simulation thread stops.

You could also try printing to stderr, which is unbuffered by tradition.