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
   | /* Exemple simple d'utilisation d une boucle do..while */
 
#include <stdio.h>
 
int choix_menu(void);
 
main()
{
	int choix;
 
	choix = choix_menu();
 
	printf("Vous avez choisi l'option %d du menu\n", choix);
	return 0;
}
 
int choix_menu(void)
{
	int selection = 0;
	do
	{
		printf("\n");
		printf("\n1 - Ajouter un enregistrement");
		printf("\n2 - Changer un enregistrement");
		printf("\n3 - Effacer un enregistrement");
		printf("\n4 - Sortie");
		printf("\n");
		printf("\nEntrez votre choix :");
 
		scanf("%d", &selection);
 
	}	while (selection < 1 || selection > 4);
 
	return selection;
} | 
Partager