Its my 1st time posting here... Do tell me if I am doing anything wrong.
cout << "Please specify a question that has a yes answer for your object and a no answer for my guess:" << endl;
getline(cin, qtn);
foundyq = qtn.find_first_not_of("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ");
while(int(foundyq) != -1)
{
if(noTry != 0 && noTry != 1)
{
cout << "This is not a question. Re-type the question and add a question mark at the end." << endl;
cout << "Please specify a question that has a yes answer for your object and a no answer for my guess:" << endl;
cin >> qtn;
foundyq = qtn.find_first_not_of("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ");
}
else if(noTry == 1)
{
cin >> qtn;
foundyq = qtn.find_first_not_of("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ");
}
else
{
cout << "This is not a question. Re-type the question and add a question mark at the end." << endl;
cout << "Please specify a question that has a yes answer for your object and a no answer for my guess:" << endl;
}
noTry++;
}
noTry = 0;
gbst.replace(nInfo, qtn);
gbst.inorderTraversal();
system ("PAUSE");
Basically, the codes I show above is to ask user to input a question which will replace a leave in my binary search tree then display in orderly.
My problem here is that after displaying "Please specify a question that has a yes answer for your object and a no answer for my guess:" , the program does not allow the user to input a question.
Results of the codes above:
Please specify a question that has a yes answer for your object and a no answer for my guess:
Book
Is it a living thing?
Human
I want the results to be like this instead:
Please specify a question that has a yes answer for your object and a no answer for my guess:
Is it an animal?
Book
Is it a living thing?
Is it an animal?