ANSWERS: 1
  • Although the sleep function is available on multiple platforms, I've only used it in Windows applications. It's usage is fairly simple, it takes 1 paramater that is the delay in milliseconds before the THREAD execution resumes. So if you wanted to pause your thread for 5 seconds (5000 milliseconds), you would use: // Start of sample C++ code Sleep(5000); // End of sample C++ code If you're a new-ish programmer and you don't know what a thread is, don't worry about that. Most likely the program you're writing won't be creating many threads so the "Sleep" function will just pause the execution of your entire program for the number of milliseconds that you supply as the parameter. You'll need to include <windows.h> to use the Sleep function on a windows application (notice the function has a capital S). I believe on other operating systems the sleep function still has only 1 parameter that represents thread delay in milliseconds but it's defined in a different header and may use a lowercase s.

Copyright 2023, Wired Ivy, LLC

Answerbag | Terms of Service | Privacy Policy