namster Posted January 22, 2011 Share Posted January 22, 2011 (edited) Salut, voila je dois réaliser un jeux du pendu enfin si on peut l'appeler Comme sa ,bon le probléme n'est pas la:(,Le code n'est pas encore fini il reste encore du boulot comme vous le voyez j'utillise une boucle Pour Affichier les ***** mais sa ne marche pas et sa me bock un peut pour continuer le programme cet lorsque je tape une lettre que les *** apparaissent. #include #include #include #include "pendu.h" int main() { int coupRestant=10; char MOTsEcret[]="MARRON"; int MotDonner[6]={0}; char lettre=0; int i=0; do { printf("Bienvenu au Jeux Du Pendu\n"); printf("Il Vous Reste %d \n",coupRestant); for (i=0;i{ if(MotDonner[i]) printf("*"); else printf("%c",MOTsEcret[i]); } printf("Proposer Une Lettre : "); lettre=getlettre(); afficherMot(MOTsEcret,MotDonner,lettre); coupRestant--; }while(coupRestant !=0); system("PAUSE"); return 0; } int afficherMot(int MOTsEcret[],int MotDonner[],char lettre) { int i=0; do { if(MOTsEcret[i]=lettre) { MotDonner[i]=1; } i++; }while(i} char getlettre() { char caractere = 0; caractere = getchar(); caractere = toupper(caractere); while (getchar() != '\n') ; return caractere; } Edited January 22, 2011 by namster Quote Link to comment Share on other sites More sharing options...
mouradski Posted January 22, 2011 Share Posted January 22, 2011 tu peux poster le fichier "pendu.h" Je ne peux pas poster une proposition de code, ou correction sans compilation Quote Link to comment Share on other sites More sharing options...
namster Posted January 22, 2011 Author Share Posted January 22, 2011 Merci Kho,mais bon Se pendu.h ne contiens presque rien char getlettre(); int afficherMot(int MOTsEcret[],int MotDonner[],char lettre); Quote Link to comment Share on other sites More sharing options...
mouradski Posted January 22, 2011 Share Posted January 22, 2011 le .c qui va avec Quote Link to comment Share on other sites More sharing options...
Krys Posted January 22, 2011 Share Posted January 22, 2011 C'est normal, tu te trompes dans les conditions à l'intérieur de la boucle Pour : [font=Comic Sans MS][color=#000000][color=#007700]for ([/color][color=#0000BB]i[/color][color=#007700]=[/color][color=#0000BB]0[/color][color=#007700];[/color][color=#0000BB]i[/color][color=#007700]{ if([/color][color=#0000BB]MotDonner[/color][color=#007700][[/color][color=#0000BB]i[/color][color=#007700]]) [/color][color=#0000BB]printf[/color][color=#007700]([/color][color=#DD0000]"*"[/color][color=#007700]); else [/color][color=#0000BB]printf[/color][color=#007700]([/color][color=#DD0000]"%c"[/color][color=#007700],[/color][color=#0000BB]MOTsEcret[/color][color=#007700][[/color][color=#0000BB]i[/color][color=#007700]]); }[/color][/color][/font] Quote Link to comment Share on other sites More sharing options...
namster Posted January 22, 2011 Author Share Posted January 22, 2011 (edited) le .c qui va avec J'ai Pas Comprie Kho ? C'est normal, tu te trompes dans les conditions à l'intérieur de la boucle Pour : [font=Comic Sans MS][color=#000000][color=#007700]for ([/color][color=#0000BB]i[/color][color=#007700]=[/color][color=#0000BB]0[/color][color=#007700];[/color][color=#0000BB]i[/color][color=#007700]{ if([/color][color=#0000BB]MotDonner[/color][color=#007700][[/color][color=#0000BB]i[/color][color=#007700]]) [/color][color=#0000BB]printf[/color][color=#007700]([/color][color=#DD0000]"*"[/color][color=#007700]); else [/color][color=#0000BB]printf[/color][color=#007700]([/color][color=#DD0000]"%c"[/color][color=#007700],[/color][color=#0000BB]MOTsEcret[/color][color=#007700][[/color][color=#0000BB]i[/color][color=#007700]]); }[/color][/color][/font] euh ? --------------------------------------------------------------------------------------------------------------- voila le code En Mini #include #include char getlettre() { char caractere = 0; caractere = getchar(); caractere = toupper(caractere); while (getchar() != '\n') ; return caractere; } void afficherMotQ(int MotDonner[],char MOTsEcret[]) { int i=0; for (i=0;i{ if(MotDonner[i]) { printf("*"); } else { printf("%c",MOTsEcret[i]); } } } int main() { char motseCret[]="MARRON"; int motdoNner[6]={0}; char lettre=0; int i=0; lettre=getlettre(); afficherMotQ(motdoNner,motseCret); } Edited January 22, 2011 by namster Quote Link to comment Share on other sites More sharing options...
namster Posted January 22, 2011 Author Share Posted January 22, 2011 (edited) Salut, Holala l'erreur de debutant if(x==y) et non pas if(x=y) Edited January 23, 2011 by namster Quote Link to comment Share on other sites More sharing options...
anubis_1001 Posted January 24, 2011 Share Posted January 24, 2011 Salut, Holala l'erreur de debutant if(x==y) et non pas if(x=y) pas forcement du debutant, ca arrive meme au expirimentés. (essaye de jongler entre deux languages comme le php et le delphi tu verra que tu n'y echappera pas) par contre un non debutant localisera l'erreur en à peine quelques minutes. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.