I was checking out clock() on cplusplus.com. Their example involves making the process wait for a second and then output a line, in a loop until 10 seconds have ellapsed. I need to do something similar in the homework assignment I’m working on. What I was wondering was this: if I just send my program into a loop, isn’t that using system resources to just spin me around? In this case, wouldn’t a system call be better?
Thanks for your help!
Yes, using a system call or library function like
sleep()is much better. Thatclock()example is just meant to just show how to correctly call the function and interpret its return value, not to illustrate the best way to make a program wait.