1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
#include <iostream>
#include <limits>
int main() {
while(1) {
int choix = 0;
std::cout << "........." << std::endl;
std::cin >> choix;
if (std::cin.eof()) {
exit(0);
} else if (std::cin.fail()) {
std::cout << "Saisie incorrecte, recommencez : ";
std::cin.clear();
std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' );
} else {
switch(choix)
{
case 1:
std::cout << "ok" << std::endl;
break;
case 7:
exit(EXIT_SUCCESS);
default:
{
std::cout << "\t\t Veuillez taper un chiffre entre 1 et 7" << std::endl;
}
break;
}
}
}
return EXIT_SUCCESS;
} |