Web Hosting Talk







View Full Version : c++ pause?


luxx
12-15-2009, 12:49 PM
Is there a way to pause a C++ program for a few seconds and then continue without any interruption?

oldunis
12-15-2009, 01:48 PM
Windows or linux?

On linux you could always issue a system("sleep 1"); make it sleep for 1 seconds.

I ain't sure, but the standard libs (ANSI) do not provide such a function (really not sure though).

mattle
12-15-2009, 01:52 PM
Discussed here: http://ubuntuforums.org/showthread.php?t=296142

plumsauce
12-15-2009, 08:27 PM
On Windows, the OS provides Sleep() or SleepEx() depending on whether you want a wakeable sleep when certain async events happen. See the PSDK which is a free download.

koso12345
12-19-2009, 11:17 PM
Try this. Make sure you use the correct headers.

int main()
{
printf("your wish is\n");
sleep(2); //seconds
printf("my command");
getch();
return 0;
}