Wait

This is a discussion on Wait within the C++ Programming forums, part of the General Programming Boards category; I'm using Borland C++. I tried a few different things that I found here on the board, faq etc. But ...

  1. #1
    Student drdroid's Avatar
    Join Date
    Feb 2002
    Location
    Montreal, Quebec
    Posts
    669

    Question Wait

    I'm using Borland C++. I tried a few different things that I found here on the board, faq etc. But none of them work. Do you know how to delay, or make a program wait, but not for system time eithor I mean regular time.

  2. #2
    looking for the truth moemen ahmed's Avatar
    Join Date
    Feb 2002
    Location
    Egypt
    Posts
    161
    you may use this


    for (i=0;i<1000;i++);


    i wish it works

  3. #3
    Fingerstyle Guitarist taylorguitarman's Avatar
    Join Date
    Aug 2001
    Posts
    564
    Doesn't Borland have a Sleep(milliseconds) function?
    I'm pretty sure it does. I don't know what header it's in though. Sorry.

  4. #4
    Fingerstyle Guitarist taylorguitarman's Avatar
    Join Date
    Aug 2001
    Posts
    564
    Or you could roll your own-

    Code:
    #include <cstdio>
    #include <ctime>
    
    void Sleep(int MilliSeconds)
    {
     // CLOCKS_PER_SEC / 1000 gives the number of system clock ticks per millisecond
     int TicksPerMilliSec = CLOCKS_PER_SEC / 1000;
    
     // Set the desired looping time value
     int LoopingTime = clock() / TicksPerMilliSec + MilliSeconds;
    
     // loop until the desired amount of milliseconds has passed
     while(LoopingTime > clock() / TicksPerMilliSec)
     {
      // just keep looping
     }
    }
    
    int main()
    {
     Sleep(2000);
    
     printf("Program running for %d seconds\n", clock() / CLOCKS_PER_SEC);
    
     Sleep(2000);
    
     printf("Program running for %d seconds\n", clock() / CLOCKS_PER_SEC);
    
     return 0;
    }

  5. #5
    Budding Synth Programmer samGwilliam's Avatar
    Join Date
    Feb 2002
    Location
    Trefforest
    Posts
    368
    Er... Borland C has always had delay (millisecs).
    MSVC++ 6.0

  6. #6
    Seņor Member
    Join Date
    Jan 2002
    Posts
    561
    It does have one called Sleep(milliseconds). The header should be in one of the following: conio.h, windows.h, dos.h, stdlib.h, or stdio.h.

  7. #7
    Student drdroid's Avatar
    Join Date
    Feb 2002
    Location
    Montreal, Quebec
    Posts
    669

    Question USED

    I've used them but not a single one works...

  8. #8
    Student drdroid's Avatar
    Join Date
    Feb 2002
    Location
    Montreal, Quebec
    Posts
    669

    Talking Thanx

    The bigger function works... Thanx

  9. #9
    Registered User
    Join Date
    Dec 2001
    Posts
    479
    u can use

    _sleep(avalue);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Why wait cursor still turning on?
    By Opariti in forum Windows Programming
    Replies: 0
    Last Post: 05-22-2009, 02:28 AM
  2. Replies: 3
    Last Post: 10-15-2008, 09:24 AM
  3. Signals, fork(), wait() and exec()
    By DJTurboToJo in forum C Programming
    Replies: 7
    Last Post: 03-18-2008, 09:14 AM
  4. Boom, Headoshot!!
    By mrafcho001 in forum A Brief History of Cprogramming.com
    Replies: 50
    Last Post: 07-21-2005, 08:28 PM
  5. anybody with experience using the wait() function?
    By flawildcat in forum C Programming
    Replies: 7
    Last Post: 04-22-2002, 02:43 PM

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