-
clock problems
Is there a way to make a something happen when a time is reached, because, I tried this code, and it doesn't work at all, I think that it could be because of clock inaccuracy that is causing it...
Code:
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(int argc, char *argv[])
{
int x;
srand( (unsigned)time( NULL ) );
x = rand() % 10;
time_t begin;
begin=clock();
if(clock() == 5000)
{
cout << x << endl;
}
system("Pause");
return 0;
}
Any thoughts?
-
Perhaps you want something like
Code:
while ( clock() < 5000 ); /* do nothing */
cout << x << endl;