Making a Timer

This is a discussion on Making a Timer within the C++ Programming forums, part of the General Programming Boards category; Could someone tell me how to make a little timer, so that i can have a line written out, wait ...

  1. #1
    Unregistered
    Guest

    Making a Timer

    Could someone tell me how to make a little timer, so that i can have a line written out, wait a couple of seconds, and then the next line out.

    eg:

    Code:
    cout << "Hello everyone";
    
    timer 5 seconds something;
    
    cout << "Okay finished";
    Any help would be most appreciated.

    Paul

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    You could try searching these forums. This question pops up every few weeks or so and has been answered quite a few times now. Perhaps a search for Prelude and sleep would come up with something like what you need.

    -Prelude
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    30

    be nice prelude

    put conio.h at top with #include's

    then put Sleep(1000) how ever many miliseconds u want in there.
    HOw are ya?

  4. #4
    Unregistered
    Guest
    Hey I tried that cnio.h sleep thing but it didn't work, i think i must have missed something:

    Code:
    #include <stdio.h>
    #include <conio.h>
    #include <iostream.h>
    
    
    int main()
    {
    cout << "Hello" << endl;
    Sleep(1000);
    cout << "Im awake!";
    
    }
    Paul

  5. #5
    Registered User
    Join Date
    Mar 2002
    Posts
    30
    dunno
    HOw are ya?

  6. #6
    Unregistered
    Guest
    try <windows.h>
    you can find the declaration there if you open the file
    it says it's obselete but works anyway

    btw, I am using the library from MSVC++ 6.0

  7. #7
    Pygmy Monkey ErionD's Avatar
    Join Date
    Feb 2002
    Posts
    408
    Depends if you are using a DOS compiler or a windows compiler.



    If DOS, include dos.h and use delay(millisecs)

    If Windows, include windows.h and use Sleep(millisecs)

    But, like Prelude said, use the search function!

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 making a dot bounce up and down y axis in this prog
    By redwing26 in forum Game Programming
    Replies: 10
    Last Post: 08-05-2006, 12:48 PM
  4. Making a timer...
    By Finchie_88 in forum C++ Programming
    Replies: 21
    Last Post: 09-04-2004, 07:15 AM

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