Does anybody know how to make a program go back to the beginning after it has completed its operations?
Thanks
-Chris
Does anybody know how to make a program go back to the beginning after it has completed its operations?
Thanks
-Chris
You could use a while or a do...while loop to loop back to the beginning. For example:
Code:#include <iostream> int main() { char quit; do { // Call functions, declare variables, do work, etc. std::cin >> quit; } while(quit != 'y' && quit != 'Y'); return 0; }
The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.
I'm no C++ expert, but try using the RUB command.
I'm not 100% sure but it's worth a try!
Why? The often unanswerable question. If it is unanswerable, why answer it?
Join the Cult of Sheograth, it's the place to be!
http://cultosheogorath.proboards16.com
Lord, we know what we are, yet we know not what we may be... Who wrote that anyway? If you know, E-Mail me. [email protected]
Joy to all the fishes...
**infected by frenchfry164**
is it possible to do this without having to ask them to input a "y"?
Yeah, you can implement that part however you want. I was just trying to demonstrate the use of a loop to go back to the beginning of the program. For example, the following code would keep running until it was shut down by a call to exit(1) or something similar somewhere in your code:
Code:int main() { while(1) { // All code, function calls, etc. to run the program. } return 0; }
The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.