Solved

Delay or Pause

Posted on 2003-10-29
4
5,623 Views
Last Modified: 2010-04-01
I'm using Borland C++ 4.5 and I want to pause my program for a few seconds.  I've tried using delay() with the <dos.h> library and it is isn't working.  What else can I used that isn't a lot of code to pause my program?
0
Comment
Question by:HuntressDi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 100 total points
ID: 9642261
Try

#include <windows.h>

Sleep ( 1000 *number_of_seconds);
0
 
LVL 10

Expert Comment

by:Sys_Prog
ID: 9642361
I guess time.h also contains a sleep function

sleep ( no_of_seconds ) ;
0
 
LVL 16

Expert Comment

by:George Tokas
ID: 9642897
Hello,
Sleep(milliseconds) blocks ANY activity on windows.
I suggest:

#include <windows.h>

int Thistick, Lasttick, Delay;
Delay = x;// x is the number you choose for your delay
Thistick = GetTickCount();
Lasttick = GetTickCount();
while(Thistick - LastTick <= Delay){
//The code to process windows messages. In BCB is Application->ProcessMessages();
Thistick = GetTickCount();}
This way will ensure that your application will NOT block the entire system at the delay..

gtokas.
0
 
LVL 3

Expert Comment

by:EarthQuaker
ID: 9644721
>Sleep(milliseconds) blocks ANY activity on windows.

Wrong.

It makes the current process idle the time of milliseconds you inputed. Not the others processes....
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
getting a fire fox page (view page source ) in c++ 6 47
Should CArray be used for a list of pointers in C++? 19 140
c++ syntax question 9 63
DCT of  2D array using fftw in c++ 9 122
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question