Click to See Complete Forum and Search --> : 1 second delay
NightSt@lker
Apr 18th, 2002, 07:20 AM
how do i do a 1 second delay between perofming commands?
NightSt@lker
Apr 18th, 2002, 05:14 PM
when i use it within a loop, it waits for 1second * number of times to loop iterates and then it prints out all the numbers at once.
I was writing a test program (countdown clock) so the loop is a s such
for(int a=10;a>=0;a--)
{
cout<<a<<endl;
Sleep(1000);
}
abdul
Apr 18th, 2002, 10:38 PM
You can't directly output a number using "cout". You'll have to convert it to a char first.
Try this:
char buffer[10];
for(int a=10;a>=0;a--)
{
itoa(a, buffer,10);
cout<<buffer<<endl;
Sleep(1000);
}
crptcblade
Apr 18th, 2002, 10:43 PM
That's not true. You can output numbers with cout.
:)
Zaei
Apr 19th, 2002, 08:24 AM
You can output anything with cout as long as it overloads the "<<" operator.
Z.
parksie
Apr 19th, 2002, 11:59 AM
Originally posted by abdul
Ahhh, never tried and knew that. I have always converted a number to a string before outputting it using cout...Now I know... That's kind of the whole POINT of the streams using the << operator ;)
Now you know why I love stringstreams :p
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.