C++ Questionmentism

Started by
4 comments, last by newbie4life 21 years, 7 months ago
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
I guess I''ll always suck.
Advertisement
Maybe you''re looking for a Do loop?

Former Microsoft XNA and Xbox MVP | Check out my blog for random ramblings on game development

do this:
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]
"after many years of singularity, i'm still searching on the event horizon"
* Zipster shouts goto and then runs like the dickens from the rest of the programmers *

  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]
[size=2]

This topic is closed to new replies.

Advertisement