void phonebookmenu() {
phonebook ph;
string str;
cin.ignore();
cout << "PH> ";
getline(cin, str); //Input from user.
string buf; // Have a buffer string.
stringstream ss(str); // Insert the string into a stream.
vector<string> tokens; // Create vector to hold the words.
while (ss >> buf){
tokens.push_back(buf); //Adds all the words inside the vector.
}
while (true){
if (tokens[0] == "add"){
ph.add(tokens[1],tokens[2]);
}
else if(tokens[0] == "lookup"){
ph.lookup(tokens[1]);
}
else if(tokens[0] == "change"){
ph.change(tokens[1],tokens[2]);
}
else if(tokens[0] == "alias"){
ph.alias(tokens[1],tokens[2]);
}
else if(tokens[0] == "quit"){
//Return to the "Main-menu"
}
else{
cout << "Invalid input" << endl;
}
}
So i'm calling this menu from a "Main-menu" but after i have input something like "Add peter 123" it does the function then returns to the "Main-menu" which i don't want. It's supposed to go back to
cout << "PH> ";
So i can continue to make operations.