delay() replacement needed!

This is a discussion on delay() replacement needed! within the C Programming forums, part of the General Programming Boards category; In school, it works since they use old versions of Borland but at home in Borland C++ 5.5.1 there is ...

  1. #1
    Mad OnionKnight's Avatar
    Join Date
    Jan 2005
    Location
    Umeň, Sweden
    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,006
    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
    Mad OnionKnight's Avatar
    Join Date
    Jan 2005
    Location
    Umeň, Sweden
    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,528
    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, 03:59 PM
  2. temperature sensors
    By danko in forum C Programming
    Replies: 22
    Last Post: 07-10-2007, 08: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, 12:23 PM
  4. delay code
    By Grayson_Peddie in forum C# Programming
    Replies: 2
    Last Post: 07-15-2003, 12:02 PM
  5. Delay
    By CanadianOutlaw in forum C++ Programming
    Replies: 4
    Last Post: 09-13-2001, 07:28 AM

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