Results 1 to 6 of 6

Thread: 1 second delay

  1. #1
    NightSt@lker
    Guest

    1 second delay

    how do i do a 1 second delay between perofming commands?

  2. #2
    NightSt@lker
    Guest
    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);
    }

  3. #3
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    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(abuffer,10);
    cout<<buffer<<endl
    Sleep(1000); 

    Baaaaaaaaah

  4. #4
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    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

  5. #5
    Zaei
    Guest
    You can output anything with cout as long as it overloads the "<<" operator.

    Z.

  6. #6
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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
  •  



Click Here to Expand Forum to Full Width