C++ Pausing

This is a discussion on C++ Pausing within the C++ Programming forums, part of the General Programming Boards category; is there a way to stop the program for an alotted time period without making it say press any key ...

  1. #1
    Perfect_Saiyan
    Guest

    Unhappy C++ Pausing

    is there a way to stop the program for an alotted time period without making it say
    press any key to continue?
    email me

    Perfect-Saiyan@shaw.ca

  2. #2
    Registered User biosx's Avatar
    Join Date
    Aug 2001
    Posts
    230
    you use the sleep(milliseconds) function in <windows.h>. It will pause the program for the amount of milliseconds without any "Press any key.." or anything.

    Have fun
    Last edited by biosx; 02-26-2002 at 01:08 AM.

  3. #3
    Johan
    Guest

    Lightbulb

    Hi!

    If you would like to pause a very short amount of time you could try:

    -----------------------
    #include <time.h>
    -----------------------

    tmrstart=(clock()/(double) CLOCKS_PER_SEC)+0.02; '0.02' is the pause value

    // A small break
    while((clock()/(double) CLOCKS_PER_SEC)<tmrstart){
    ;
    }

    /Johan

  4. #4
    Unregistered
    Guest
    or not the prettiest way but yuo could also create a nested for loop which would delay the program, but again not the most efficient

    for(int k = 0; k<10000; k++)
    {
    for (int j = 0;j<10000;j++)
    {}
    {

    and modify the 10,000 according to how much delay you want

  5. #5
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    >>> you use the sleep(milliseconds) function in <windows.h>.

    The function is Sleep() not sleep(), (S not s). If you are not using Windows it may be sleep() or wait() or alarm() or possibly something else.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pausing script to read output
    By a_priebe47 in forum C Programming
    Replies: 1
    Last Post: 06-15-2004, 11:16 PM
  2. pausing functions..
    By bluehead in forum C++ Programming
    Replies: 3
    Last Post: 01-13-2002, 03:27 AM
  3. Functions and pausing
    By dv916 in forum C++ Programming
    Replies: 4
    Last Post: 12-28-2001, 05:43 PM
  4. MS DOS not pausing while waiting for imput.
    By Jeremy G in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 11-14-2001, 09:06 PM
  5. pausing the system
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 10-18-2001, 01:34 PM

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