I wrote a console program which is getting some spesific character inputs from user to perform operations. Program asks for an input, user types "i" for insert or "r" for remove etc.. The problem is when user types more than one letter, the program behaves weird.
char selection;
bool finish = false;
while (!finish){
print_menu();
cin >> selection;
finish = perform_operation(selection);
}
This is how i get the user input. And i want to get just the first character of the user input and ignore the rest of them, and behave so on. How can i do it?
Note: I'm not allowed to use "string" class, but i can use every str functions!
Thanks for help!
Another case:
What if i would like to get spesific amount of characters? For example: the user inputs a name which is 10 characters but i want to get just the first 5 characters. What should i do?