d00 ex01 correction erreur affichage index en cas de simple retour a la ligne

This commit is contained in:
hugogogo
2022-03-14 13:29:13 +01:00
parent 2e68c5daef
commit 3f0c94360a
2 changed files with 1 additions and 1 deletions

View File

@@ -133,7 +133,7 @@ void PhoneBook::search_contact() {
if (!std::getline(std::cin, index))
return;
id = std::strtol(index.c_str(), &ret, 10);
if (*ret || id < 0 || id > this->_contact_count - 1 || id > 7)
if (*ret || index.empty() || id < 0 || id > _contact_count - 1 || id > 7)
std::cout << B_RED "sorry, not a valid index" RESET << std::endl;
else
break;