|
-
Apr 18th, 2002, 07:20 AM
#1
1 second delay
how do i do a 1 second delay between perofming commands?
-
Apr 18th, 2002, 05:14 PM
#2
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);
}
-
Apr 18th, 2002, 10:38 PM
#3
PowerPoster
You can't directly output a number using "cout". You'll have to convert it to a char first.
Try this:
PHP Code:
char buffer[10];
for(int a=10;a>=0;a--)
{
itoa(a, buffer,10);
cout<<buffer<<endl;
Sleep(1000);
}
-
Apr 18th, 2002, 10:43 PM
#4
That's not true. You can output numbers with cout.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Apr 19th, 2002, 08:24 AM
#5
You can output anything with cout as long as it overloads the "<<" operator.
Z.
-
Apr 19th, 2002, 11:59 AM
#6
Monday Morning Lunatic
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
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|