void LList::TitleS(int counting){
//PRE:
//POST:
string key = "blank";
int position;
string use;
while(key != "exit" && key != "EXIT"){
bool found = false;
cout << "Enter the title to search for or type (exit) to return ";
cout << "to search menu: ";
getline(cin, key);
if(key != "exit" && key != "EXIT"){
listnode * temp;
temp = head;
for(int i = 0; i < counting && !found; i++){
use = temp->Ltitle;
if(use != key)
temp = temp->next;
else{ //if(use == key)
found = true;
position = 1;
}
}
if(found)
Display(position);
else
cout << "Book Title NOT found" << endl;
}
else
;
}
}
Using the code above I'm recieving some weird occurances in my execution. For some reason it's reading in before I input any information. What happens is below.
Search for book code (b) or title (t) or enter (end) to end the program: t
Enter the title to search for or type (exit) to return to search menu: Book Title NOT found
Enter the title to search for or type (exit) to return to search menu:
I had to use this in a program where I had a getline and then I had to use another getline directly after that. I only see one getline in your code, but if I missed another getline in there here is some code. Also, the variable "use" is not initialized anywhere which may cause some conflict.
1 2
cin.ignore(); // Needed in order to allow new input.
getline(cin, key);