Created
December 6, 2011 19:51
-
-
Save titouanc/1439663 to your computer and use it in GitHub Desktop.
Les menus utilisateurs en C, c'est ennuyant !
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Problème: le caractère de retour a la ligne, ainsi que chaque caractere supplémentaire sur la ligne, | |
* provoque un tour de boucle inutile | |
*/ | |
while (1) { | |
printf(" > "); | |
scanf("%c", &choix); | |
switch (choix){ | |
case '1': return MOYENNE; | |
case '2': return ECARTTYPE; | |
case '3': return INTCONFIANCE; | |
case '4': return COEFVAR; | |
case '5': return FREQREL; | |
case '6': return QUITTER; | |
default: printf("%c n'est pas un choix reconnu !\n", choix); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Problème: Tombe en boucle infinie si le caractère entré ne peut être traité par %d | |
*/ | |
#define entre(min,n,max) ((min)<=(n) && (n)<=(max)) | |
while (! entre(1, choix, 6)) { | |
printf(" > "); | |
scanf("%d", &choix); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment