Delay

This is a discussion on Delay within the C++ Programming forums, part of the General Programming Boards category; Hi there! I looking for a simple function to do a delay in my programs, I could'nt find one on ...

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    1

    Question Delay

    Hi there!
    I looking for a simple function to do a delay in my programs,
    I could'nt find one on the libraries listed on the net.
    I've tried do one witch for loops, but my computer is fast, and there's no effect.
    So, if someone could help.

    thanks!

  2. #2
    _B-L-U-E_ Betazep's Avatar
    Join Date
    Aug 2001
    Posts
    1,412
    do a search for Sleep() on the boards....
    Blue

  3. #3
    Registered User biosx's Avatar
    Join Date
    Aug 2001
    Posts
    230
    Sleep( ) is a good one, also there is delay( ) which is defined in dos.h.

    Good luck.

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    104
    just to mention, the Sleep() function requires windows.h
    Ilia Yordanov,
    http://www.cpp-home.com ; C++ Resources

  5. #5
    Unregistered
    Guest

    Talking Try this!!

    #include <iostream>
    #include <ctime>
    using namespace std;

    void sleep()
    {
    double seconds = 1.5;
    clock_t timer;
    timer = clock() + seconds * 1000;
    while (clock() < timer) {}
    }

    int main()
    {
    cout << "I am now!!!" << endl;
    sleep();
    cout << "I am 1.5 seconds later" << endl;
    return 0;
    }

    I think this should work, if I remember I got it correct
    Good luck!!

  6. #6
    Registered User loopy's Avatar
    Join Date
    Mar 2002
    Posts
    172

    huh?

    What liberaries posted on the net, i sure would like to see that.
    WorkStation(new, a month ago):

    Sony Vaio i686 Desktop
    2.60 GIGhz Intel Pentium 4(HT)
    512Mb DDR RAM
    800MHz Front Side Bus!
    120 GIG IDE HardDrive
    Matrox G400 Dual-Head
    Linux kernel 2.6.3
    Modified Slackware 9.1
    GCC/GDB

    Multi-mon
    Simultaneous Multiple Processes

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. 2-3 Second delay with alarm()
    By Longie in forum C Programming
    Replies: 11
    Last Post: 06-20-2004, 09:46 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