Time delay function

This is a discussion on Time delay function within the C++ Programming forums, part of the General Programming Boards category; Hello everyone. Is there a time delay function defined in ANSI/ISO C++, perhaps similar to sleep() or delay() of Borland ...

  1. #1
    Registered User
    Join Date
    Jun 2002
    Posts
    79

    Time delay function

    Hello everyone. Is there a time delay function defined in ANSI/ISO C++, perhaps similar to sleep() or delay() of Borland C++?

  2. #2
    Registered User Cela's Avatar
    Join Date
    Jan 2003
    Posts
    362
    >>Is there a time delay function defined in ANSI/ISO C++
    Nope, you have to roll your own or use a nonstandard function offered by your compiler :-)
    *Cela*

  3. #3
    Registered User
    Join Date
    Jan 2003
    Posts
    648

  4. #4
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Code:
    void mySleep(float seconds)
    {
        using namespace std;
        clock_t goal_time = clock() + static_cast<clock_t>(seconds*static_cast<float>(CLOCKS_PER_SEC));
        while (clock() < goal_time);
    }
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  5. #5
    Registered User
    Join Date
    Jun 2002
    Posts
    79
    Thanks Sang-drax, that did the trick. I will try to figure out how exactly the code works soon enough.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 01:53 AM
  2. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 09:18 AM
  3. The space time continueimnms mm... (rant)
    By Jeremy G in forum A Brief History of Cprogramming.com
    Replies: 32
    Last Post: 06-27-2004, 01:21 PM
  4. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 06:18 AM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM

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