I need to wait for short intervals of time in my program, but I really don't want to include unistd.h
just to use sleep
, so I'm doing it this way:
int main()
{
for(int i=0; i<=100000000000; i++); // <----- note that the loop doesn't do anything
return 0;
}
I do this when I don't really have a specific interval to set for sleep.
Is there anything wrong with this? Would this harm the program in any way?
In C I know that if I did include unistd.h
, and that if I used sleep()
, that the following code would also make the program wait for a short interval of time:
int main()
{
sleep(2000); //or whatever the number (in milliseconds)
return 0;
}