What is file do you need to include to use the sleep() function? or are there any other functions better suited for pausing a program?
What is file do you need to include to use the sleep() function? or are there any other functions better suited for pausing a program?
windows.h
I'd just like to point out that it is trivial to write your own "sleep" function. All you need is a very basic understanding of timers.Originally posted by Munkey01
What is file do you need to include to use the sleep() function? or are there any other functions better suited for pausing a program?
"...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers
True, but there are many times where you don't want to pause the process IE if you want other things to go on in your program while the timer is running such as graphics being updated, etc.Originally posted by vVv
And I'd just like to point out that I think I know what you're thinking of, and that I guess it'll be a useless (for serious code), ugly kludge.
See here for an example.
Though, yeah, in the information he provided, sleep is better.
There's no need to get ugly about it I just always think its a good exercise to write some things yourself first then use the already existant function call. Another good example of this is all of the string functionality ( i.e. strlen, strcat, etc. ) You'll learn a little more if you do it yourself. Then, knowing the underworkings, you can feel free to use the before-mentioned function. Thats just my opinion though.Originally posted by vVv
>I'd just like to point out that it is trivial to write your own "sleep" function.
And I'd just like to point out that I think I know what you're thinking of, and that I guess it'll be a useless (for serious code), ugly kludge.
See here for an example.
I believe the point vVv was making is that the home brewed sleep() is, unless done properly, incorrect. By timers you might be refering to windows code which is a bit different, but using timeres in that instance would be a waste I think.
Multithreading simply because you want to be able to have a timer going as another part of your program is running is not very wise.Originally posted by vVv
In that case you'll use threads or more than one process either way.