Im a Beginners and I need help!



#include<iostream>
#include<string>
using namespace std;
void magicSentence();
int main() {
magicSentence();
return 0;
}
void magicSentence() {
string word = "";
cout << "Enter a word (exit): ";
cin >> word;
if (word == "exit") {
//do nothing
}
else {
// call it again - recursion
magicSentence();
cout << word << " ";
}
}
Last edited on
This is not a homework site. We won't do your homework for you. However we are always willing to help solve problems you encountered, correct mistakes you made in your code and answer your questions.

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.
@adilas do you really think that in the statement exit you code nothing ? Recursive functions are very short and very fast , it can create a stack overflow if you dont pay attention.
Topic archived. No new replies allowed.