Thread: delay() replacement needed!

  1. #1
    Registered User OnionKnight's Avatar
    Join Date
    Jan 2005
    Posts
    555

    delay() replacement needed!

    In school, it works since they use old versions of Borland but at home in Borland C++ 5.5.1 there is no delay(), has it been replaced with something else? I'd like to know.
    I've heard of Sleep() but that didn't seem to work because I don't know where it is and Google doesn't know more than I do on this matter.

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    FAQ > How do I... (Level 2) > Sleeping
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
    for( ;; );
    That'll delay your program...

    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    Registered User OnionKnight's Avatar
    Join Date
    Jan 2005
    Posts
    555
    Code:
    void wait(long milliseconds)
    {
      long timeout = clock() + milliseconds;
      while( clock() < timeout ) continue;
    }
    I used that one from the FAQ and I have to say it works even better than delay(), somehow feels smoother. Thanks!

  5. #5
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,534
    Quote Originally Posted by quzah
    Code:
    for( ;; );
    That'll delay your program...

    Quzah.
    heh - I like this one:

    Code:
    int main(void)
    {
      delay_start:
        goto delay_end;
      delay_end:
        goto delay_start;
        return 0;
    }
    ~/

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Regarding delay in the connection
    By byatin in forum Networking/Device Communication
    Replies: 2
    Last Post: 08-19-2008, 02:59 PM
  2. temperature sensors
    By danko in forum C Programming
    Replies: 22
    Last Post: 07-10-2007, 07:26 PM
  3. Networking (queuing delay, avg packet loss)
    By spoon_ in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 09-05-2005, 11:23 AM
  4. delay code
    By Grayson_Peddie in forum C# Programming
    Replies: 2
    Last Post: 07-15-2003, 11:02 AM
  5. Delay
    By CanadianOutlaw in forum C++ Programming
    Replies: 4
    Last Post: 09-13-2001, 06:28 AM