|
From: Chris B. <ch...@cb...> - 2000-10-21 18:00:06
|
Hello,
Does anyone know a way around this problem:
I have written a function that delays for secs amount of seconds:
#include <ctime>
void pause(int secs)
{
time_t current, end;
current =3D clock();
end =3D current + CLOCKS_PER_SEC * sec;
while(current < end)
current =3D clock();
}
The problem is when I try to use it as follows:
int main()
{
int t =3D 10;
cout << "Count down: ";
while(t >=3D 0)
{
cout << t-- << " \r";
pause(1);
}
return 0;
}
The program executes but doesn't displa the count down numbers until the =
time is up - then it just displays 10.
The program works fine though if I use printf() instead of cout! Why is =
this - I want it to work with cout! Is is something to do with buffers?
Thanx in advance.
Chris.
|