Bonjour,
j'ai un code ou je veux écrire des phrases et les afficher.
Ce code fonctionne très bien sans un switch mais avec celui-ci, ça boucle
et il ne m'inscris rien????????
Merci d'avance pour votre aide et je met mon code ci-après....
J'ai utilisé fgets pour écrire ma phrase, est-ce la mon erreur?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
int main(int argc, char *argv[])
{
int choix;
char l[100], c[100]={0};
while(choix!=0)
{
printf("\n-1- affiche la question 1");
printf("\n-2- affiche la question 2");
printf("\n-2- affiche la question 3");
printf("\n votre choix=============>");
scanf("%d", &choix);
switch(choix)
{
case 1:
printf("salut,encode ta phrase : ");
fgets(l,100,stdin);
break;
case 2 :
printf("Ha ta phrase est %s", l);
break;
case 3 :
printf("je copie ta reponse dans une autre variable");
strcpy(c,l);
printf("%s", c);
break;
}
}
getch();
return 0;
}
Configuration: Windows XP
Firefox 2.0.0.12