Bonjour a tous,

Voila, je débute tout juste en C ( mis pas en programmation), et je bute sur un probleme dans un switch.Voici mon code

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
41
42
43
44
45
46
 
int main()
{
    //  VARIABLES GLOBALES
    etudiant classe_etu[NB_ELEVES];
    int choixMenu;
    char nometu[50]; // Nom etudiant à chercher
 
    init(classe_etu); // appel de la procedure init
	choixMenu=99;
    while( choixMenu != 0 )
    {
        system( "cls" );
 
        printf("------------------------------\n");
        printf("-- Gestion des etudiants\n");
        printf("------------------------------\n\n");
 
        printf("\n\n------- Menu Principal -------\n\n");
        printf("1 - Insertion des etudiants\n");
        printf("2 - Affichage des etudiants\n");
        printf("3 - Rechercher un etudiant\n");
        printf("0 - Quitter");
        printf("\n\n------------------------------\n\n");
 
        // Choix du menu
        printf("Votre choix : ");
        scanf("%d", &choixMenu );
 
        // Gestion du choix
        switch( choixMenu )
        {
            case 1 : insertion(classe_etu); break;
            case 2 : affichage(classe_etu); break;
            case 3 : {      printf( "Taper le Nom a chercher : " );
                            scanf( "%s", &nometu );
                            recherche(classe_etu, nometu);
                     } ; break;
            case 0 : printf("\n\nProgramme termine. Merci"); break;
            default : printf( "Mauvais choix...Recommencez\n" );getch();
        }
    }
 
	return 0;
}
// Fin Programme Principal
Alors j ai deux questions

1) comment tester si ma variable choixMenu est un char ou un int ?


2)Et si choixMenu est égal a des lettres il lance "recherche" qui est une fonction appelé si je tape "3". Pourquoi fait il ca ? :/

des idées?