C++ Questionmentism
I was wondering if, in C++, there is a way to link the end of a function to the middle of the same function so that it loops.
For example:
#include <iostream>
#include <string
int main()
{
string blah;
cin>> blah;
cout << "The word you typed is " << blah << endl;
}
How would I make it repeat the output over and over again without making it a seperate function?
thanx,
-Newbie
do this:
[edited by - DerekSaw on August 26, 2002 2:18:09 AM]
for( ; ; ){ cout << "Somebody stop me!" << endl;}//------- OR -------while(true){ cout << "Somebody stop me, please!" << endl;}//------- OR -------do{ cout << "STOP ME!" << endl;}while(true);
[edited by - DerekSaw on August 26, 2002 2:18:09 AM]
int main(){start: cout << "dont use goto in programming c++ programs" << endl;goto start;return 0;}
Its my duty, to please that booty ! - John Shaft
#include <iostream>#include <string>using namespace std;int maint( void ){ string my_input; do { cin >> my_input; cout << "The word you entered: " << my_input << endl; } while( my_input != "QUIT" )}
[edit] Source tags own me
[My site|SGI STL|Bjarne FAQ|C++ FAQ Lite|MSDN|Jargon]
Ripped off from various people
[edited by - wild_pointer on August 26, 2002 6:18:27 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement