Thread: some kind of timer...

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    16

    some kind of timer...

    I'd like to do a proggy that will count to - for example - 100 in one seconds interval... and execute some code in every second... any ideas???

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    time.h

    clock()
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  3. #3
    Registered User
    Join Date
    Jun 2002
    Posts
    267
    or you could use Sleep()

    Code:
    #include <windows.h>
    ...
    for (int i = 0; i < 100; i++)
    {
              some code
              Sleep(1000) // pause for 1 second (1000 milliseconds)
    }
    Sleep is an Win32 API command; it's simple and gets the job done.
    Last edited by d00b; 07-31-2002 at 03:22 PM.

  4. #4
    Registered User
    Join Date
    Jul 2002
    Posts
    16
    thank you both guys, especially for d00b !!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. SIGALRM and timer
    By nkhambal in forum C Programming
    Replies: 1
    Last Post: 06-30-2008, 12:23 AM
  2. tic tac toe crashes :(
    By stien in forum Game Programming
    Replies: 4
    Last Post: 05-13-2007, 06:25 PM
  3. Need help with a count down timer
    By GUIPenguin in forum C# Programming
    Replies: 0
    Last Post: 07-07-2006, 04:18 PM
  4. Timer again.
    By geek@02 in forum Windows Programming
    Replies: 1
    Last Post: 05-04-2005, 10:19 PM