Programme C défile sans s'arrêter
Résolu
Lotte
-
Lotte -
Lotte -
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...");
}
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...");
}
A voir également:
- Programme C défile sans s'arrêter
- Programme demarrage windows - Guide
- Message programmé iphone - Guide
- Mettre en veille un programme - Guide
- Programme word gratuit - Guide
- Cette action ne peut pas être réalisée car le fichier est ouvert dans un autre programme - Guide
2 réponses
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>
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>