I'm sorry for the weird title but i really don't know how to say this. Look:
std::array<std::string, 2> names = { "chloe", "tom" };
std::string choice;
std::cout << "Type a name.";
std::getline(std::cin, choice);
std::for_each(choice.begin(), choice.end(), [](char& c) {
c = ::tolower(c);
});
for (int i = 0; i < names.size(); i++) {
if (choice == names[i]) {
std::cout << choice;
}
}
This code lets the user input a name and if the name is inside the names array it gets printed. What i want to do is that as soon as the user types a correct name (chloe for example), even without having to press enter the program recognizes it as correct and proceeds.