Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wait/Pause an amount of seconds in C

Tags:

c

windows

I wrote a little console application, and I want it to pause for a certain number of seconds before the cycle (a while) starts again.

I'm working on Windows operating system.

like image 833
Ldx Avatar asked Feb 11 '12 14:02

Ldx


1 Answers

On UNIX:

#include <unistd.h>
sleep(10); // 10 seconds

On Windows:

#include <windows.h>
Sleep(10000); // 10 seconds (10000 milliseconds)

Note the difference between sleep() (UNIX) and Sleep() (Windows).

like image 100
cespon Avatar answered Sep 29 '22 09:09

cespon