sleep(int) in C++
#include <iostream>
#include <time.h>
using namespace std;
void sleep(unsigned int seconds)
{
clock_t goal = seconds*1000000 + clock();
while (goal > clock());
}
int main ()
{
int num=1;
for( ; ; )
{
cout << "This loop will run forever. " << num << endl;
num++;
sleep(1);
}
return 0;
}
#include <time.h>
using namespace std;
void sleep(unsigned int seconds)
{
clock_t goal = seconds*1000000 + clock();
while (goal > clock());
}
int main ()
{
int num=1;
for( ; ; )
{
cout << "This loop will run forever. " << num << endl;
num++;
sleep(1);
}
return 0;
}