Programme C défile sans s'arrêter

Résolu/Fermé
Lotte - 28 juil. 2010 à 12:46
 Lotte - 28 juil. 2010 à 15:25
Bonjour,
je suis en train d'apprendre le C donc je suis désolée si le problème paraît évident ^^"
Lors de la compilation du programme, pas d'erreur mais lorsque je l'exécute le programme ne "s'arrête pas" dans le sens où le texte défile sans s'arrêter. J'ai tout regardé, mais je ne vois pas l'erreur. Quelqu'un pourrait-il m'aider svp ?

Merci d'avance.

Voici le code :

#include <stdio.h>
#include <stdlib.h>
#define QUIT 3

int choix_menu(void);
void affiche(void);

int main()
{
int choix = 0;

while(choix != QUIT)
{
choix = choix_menu();

if(choix == 1)
printf("\nL'ordinateur va biper \a\a\a");
else
{
if(choix == 2)
affiche();}
}
printf("Vous avez choisi de sortir!\n");
system("pause");
exit(EXIT_FAILURE);}


int choix_menu(void)
{
int selection = 0;

do
{
printf("\n");
printf("\n1 - Bip ordinateur");
printf("\n2 - Affichage");
printf("\n3 - Sortir");
printf("\n");
printf("\nEntrez votre choix :");

scanf("&d", &selection);

}while (selection < 1 || selection > 3);

return selection;
}

void affiche(void)
{
printf("\nExemple d'affichage");
printf("\n\nOrdre\tSignification");
printf("\n======\t==============");
printf("\n\\a\tsonnerie ");
printf("\n\\b\tretour arriere");
printf("\n...\t\t...");
}



2 réponses

varfendell Messages postés 3256 Date d'inscription jeudi 27 décembre 2007 Statut Membre Dernière intervention 8 février 2020 699
28 juil. 2010 à 13:40
Bonjour,

Deja remplacer

<code#include <stdio.h>
#include <stdlib.h>
#define QUIT 3

int choix_menu(void);
void affiche(void);

int main()
{
int choix = 0;

while(choix != QUIT)
{
choix = choix_menu();

if(choix == 1)
printf("\nL'ordinateur va biper \a\a\a");
else
{
if(choix == 2)
affiche();
}
}
printf("Vous avez choisi de sortir!\n");
system("pause");
exit(EXIT_FAILURE);
}


int choix_menu(void)
{
int selection = 0;

do
{
printf("\n");
printf("\n1 - Bip ordinateur");
printf("\n2 - Affichage");
printf("\n3 - Sortir");
printf("\n");
printf("\nEntrez votre choix :");

scanf("&d", &selection); ===> scanf("%d", &selection);

}while (selection < 1 || selection > 3);

return selection;
}

void affiche(void)
{
printf("\nExemple d'affichage");
printf("\n\nOrdre\tSignification");
printf("\n======\t==============");
printf("\n\\a\tsonnerie ");
printf("\n\\b\tretour arriere");
printf("\n...\t\t...");
} </code>

0
Ah je vous remercie, c'était ça !
Pourtant, j'pensais avoir fait attention. Ca ne tient pas à grand chose ^^

Merci beaucoup.
0