Question not "looping" correctly

Im trying to make a program that will sort out the quests which you can do, based on levels and previous quests completed, for the game Runescape. This part of the program is supposed to ask you if you need to input another quest you have finished, and so when you say yes, you type it in. The values reset so it wont go into an infinite loop (this happened to me the first time i tested it). Then it will ask again.

The problem is that when it runs the cout part of the code after the first time you input the information, it stops with a system("pause") sort of thing, and the cin code is not ran, so the "loop" stops. I put loo[ in quotes since its obviously not a literal loop.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  void typeQuest(){
     cout << "Another Quest to type?\n";
     cout << "1: Yes\n";
     cout << "2: No\n";
     cin >> yesInput;
         if(yesInput == 1){
              qn = qn + 1; //Makes sure that when the value is put in it wont override the last bit of input
              cin >> done[qn + 1]; //Put the value into an array to be checked later
              yesInput = 0; //Reset the value
              typeQuest();
              }
         else{
              checkQuest(); //This is the code which will be implemented that runs the process of seeing which quests you can or can't do.
              }
     }


Thanks for reading and I hope you can help :D
Last edited on
You never defined qn.
Same goes with done.
What are these?
Done is an array which puts what quests you have done

 
string done[] = {"","","","","","","","","",............} //theres more quotes here          


and qn was defined earlier
 
int qn = 0;


This was only a part of the whole code
Last edited on
Bump? Please i need help.
Recursion doesn't strike me as being necessary. Why not use a normal loop?
Presumably your "quests" consist of more than one whitespace delimited token, in which case using the extraction operator isn't appropriate. Any time you enter more than one word for the quest, words other than the first remain in the input stream, and assuming yesInput is a numeric type, cause cin to enter a failure state on line 5 of your function (where it expects to find numeric input) in subsequent iterations.
Last edited on
Cire is right.
If you're putting a string in done, you'll need to use "getline" to catch every word.
Also, I think it wouldn't hurt if you write "cin.ignore()" before "cin >> yesInput". It keeps your program from skipping the choice because of the input stream.
I hope it helps.
Topic archived. No new replies allowed.