I am wondering if I can loop x times in one minute interval between each loop.
for (int x = 10; x > 0; x--)
{
cout << "BOOM" << endl;
}
Is there any way I can print boom every one minute?
Or there is a better way to do this?
Thank you
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Standard C++ has no such function. The closest thing you could do is have an infinite loop constantly asking if a minute has gone by.
The draft C++0x standard has
sleep_until()andsleep_for()under the header<thread>, but your implementation may not support these features yet (they aren’t standard yet anyway), and it may be more work than it’s worth.Consult your implementation documentation. There’s probably a sleep() function or something like that, and you could put something like
sleep(60)in your loop.