Archived

This topic is now archived and is closed to further replies.

C++ Questionmentism

This topic is 5592 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

  
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

Share this post


Link to post
Share on other sites

    
#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]

Share this post


Link to post
Share on other sites