I know this question has been asked hundreds of times, but How do you...

This is a discussion on I know this question has been asked hundreds of times, but How do you... within the C++ Programming forums, part of the General Programming Boards category; I need help on making the program wait abit. I can use wait(), but for some reason, it locks up ...

  1. #1
    Banned frenchfry164's Avatar
    Join Date
    Oct 2001
    Posts
    1,552

    I know this question has been asked hundreds of times, but How do you...

    I need help on making the program wait abit. I can use wait(), but for some reason, it locks up the comp when I try it in 13h mode. I tried doing a for loop that doesnt do anything for abit, but once I get the number up high enough for a noticable pause, the one thing where if something repeats enough the program aborts.

    I just need a pause for so many seconds routine.

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    7
    If you're programming for the Windows platform you can use the Win32 API function 'Sleep'. If your program is running exclusively on its own and you don't care how much CPU it takes up, you can write your own wait function with the functions in <time.h> (<ctime>):

    void Wait(int iSeconds)
    {
    time_t iEnd = time() + iSeconds;

    while (time() < iEnd)
    ;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Exam Question - Possible Mistake?
    By Richie T in forum C++ Programming
    Replies: 15
    Last Post: 05-08-2006, 04:44 PM
  2. I need help to compile this code...
    By wise_ron in forum C Programming
    Replies: 17
    Last Post: 05-07-2006, 01:22 PM
  3. Question about binary trees and files
    By satory in forum C Programming
    Replies: 9
    Last Post: 03-06-2006, 06:28 AM
  4. Very simple question, problem in my Code.
    By Vber in forum C Programming
    Replies: 7
    Last Post: 11-16-2002, 03:57 PM
  5. A question asked a million times, but where do I start?
    By Unregistered in forum Game Programming
    Replies: 10
    Last Post: 09-09-2001, 10:15 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21