From 16f081c454369959c842c08d36920fa55bdbc206 Mon Sep 17 00:00:00 2001 From: landrin Date: Fri, 25 Oct 2024 18:43:33 +0200 Subject: [PATCH] correctif bug save file --- exependu | Bin 0 -> 17656 bytes pendu.c | 30 +++++++++++++++++++++--------- save_party.txt | Bin 103 -> 110 bytes 3 files changed, 21 insertions(+), 9 deletions(-) create mode 100755 exependu diff --git a/exependu b/exependu new file mode 100755 index 0000000000000000000000000000000000000000..c6b9edc565c30cfed73c7b960c83606675eb0958 GIT binary patch literal 17656 zcmeHPe{@vUoxhVG5D}8#0wT2XP}#z2hJb)Uq-H_}UfdwRg<5ek%uJHe$xNJiBf)}( zGsI?=tXg`u>!Iu-V2VLc-2*N4(4%dsD>f0-7`0-n&VIi4-S5kr z$4u+-^q-#Q>dW_jKll6n-h03I=e+wa4|yAx7P(x4L$Ua(Ag<{O6RA}RHH%dQq*m03 zariq;TrEa{FOis;UTYGhn&C`QE-h1dF(~Oxrbr(8B@-4*xr9VXuTUtv+)QCADovjB zN-3&%C;d?AG39hCKaG?TH2K$}9nz=}OznE)o0=+9p8dykgQ|CvqO3>mB0XK{>B{d+ z2dO{^Oxd606MAZtJtx(WMnRK*g>dR|d7QLf$up%qD6BbW1iwgrE0x~XYfU>&8Z=?S zl=E8!J@U)v4cyGDxts;s;e_g+OqF}Z>_~Xif_bwe!Kz3&n(V0Rs98|8V4gb>bI+AU zpmI?j)cnhCUngMZC}G^36rZ4YO8@Si)n$+E`jz{oSEq?<@BG=o4}SIjx7Y^dNiq~j zUlmF66rY5LWX$?+mpEY*PKExr&5Y&$dl0aeC+TirYKZ5g1`6P-3gEXDz{yMb>@O*R zZ!Cb{QvhFI0DrguPHmO1Jl7Y%PXpKRIKyfH`Rq`8F*ig5`H`jfW6`NR8f_@e)c6=j~rT@mI``fJ8X+yyxoD9A)KlzQKX7PkFii8 z_So>THhixQ$H1||J{w+Pp+X$6;XLLj`JfG_Igi6p8*ZNmPuOrZw4};O8$OYZjL;De zjCf$g1Am1c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VG z{l=D1j9VO9Uc6k?=IKYpqC%|9i&t9rMQrBb&GCZgyIdS!>S=bwj2B}v<@*5k)MEUq zJbSGjVfl&H_qF!aVtg^r^JXr7rN}pKi!lrFJeMnvS-RGanDJsUMfBvwc@`hmq3N9K#b2#gMq2tVq;rz@P-8?Z9mgugCZc_=>$OYyk!_@NCr*|*j& z5=Pj9$0aWH=N{ns%3r8nd!?NT!kB@GBjmI5jFg#pNqf;zpG#cYUMG}1ubZ63t1@zF z|9MB+xwL(|unrYbD>(W;9lc!v@T_V|URNgo*Elm9y&iTnacMuPR(8tN$G>i+L&xZj zrj;r5uAvfkoc(G^0r~X>@N&Y7E**FG6p(+g0RFE9@Mk1mDHf=D$#*TN0e!lVuU@AL z;Ph@PpZrG!@JaA|o7uH}kK?rXru7hNTs>tHkCl(SNzS4R{! z6ewp>%3me4S}7*lO(MPlocdL}>Q^C!(*b)W#_yh51t>CG$v3G=&sKN_ILY@o^voL#n{LZCI6O^m+#_`{!#(?HwxgtD}ax|I!b@aUR^{!QKq4uN{73K3;F6E86|eUrICb%bf_}rV?(fvr@|7IA zej{)Bo+NVru?3T^LN(&F{NLp4D#jUsHM(r9@kBm>1tenq8lNuQFwMHo-j80}g%uUCY#dc1bo^ zkLiyb`n*qL+Ql!pNEw0kOil>%_sy{X_;)f>eqYG)&hc{`2~>Y>f1xQ!MR^=5)M`KG zUq-~P&%e8w23b&1Xa27`^!fKWQ|>=(hWiim=MX8!qoy6}cRc@l2~K(DnZ5_z3Y$Lv z-mk3!h`@3tH_S6m}=g;p2_}^U^BdkqGPa`-2*_Q9nV-w!rx^ z9R+2(zNl5g)h6w+=~7g4@N||Lsp7jk)c{-xo;Ww)t|lQkyS=t$&zS(aWyIYeaAmu@j7rZ^NFtoVOZ Cx5y3v literal 0 HcmV?d00001 diff --git a/pendu.c b/pendu.c index f0602ef..c8bb158 100644 --- a/pendu.c +++ b/pendu.c @@ -43,9 +43,12 @@ this function allow to save the last party Parameters: status -> state that save if the gamer win or lose the party good_word -> the word to guess - try -> the letters try by the gamer + try -> the wrong letters try by the gamer + cpt_try -> the try's table size + good_try -> the good letters try by the gamer + cpt_good_try -> the good_try's table size */ -void save_party(char * status, const char * good_word, char try[]) { +void save_party(char * status, const char * good_word, char try[], int cpt_try, char good_try[], int cpt_good_try) { time_t t; time(&t); //stock the current time char * date; @@ -68,12 +71,18 @@ void save_party(char * status, const char * good_word, char try[]) { fputs("\n",fichier); fputs("tried letters: ", fichier); - for (int i = 0; i < sizeof(char*); i++) { + for (int i = 0; i < cpt_try; i++) { fputc(try[i],fichier); } fputs("\n",fichier); + + fputs("guessed letters: ", fichier); + for (int i = 0; i < cpt_good_try; i++) { + fputc(good_try[i],fichier); + } + fputs("\n",fichier); - fclose(fichier); // On ferme le fichier qui a été ouvert + fclose(fichier); // Close the opened file } } @@ -133,7 +142,9 @@ int main() { char guessed[word_length]; int tries = 0; int guessed_correctly = 0; - char try[MAX_TRIES]; //save the carcater try + char try[MAX_TRIES]; //save the carcater false + char good_try[word_length]; //save the carcater good + int cpt = 0; signal(SIGALRM,sig_handler); @@ -153,7 +164,6 @@ int main() { printf("Entrez une lettre : "); alarm(30); scanf(" %c", &guess); - int found = 0; @@ -163,7 +173,6 @@ int main() { if (guessed[i] == '_') { guessed[i] = guess; guessed_correctly++; - try[tries] = guess; } found = 1; } @@ -172,16 +181,19 @@ int main() { if (!found) { try[tries] = guess; tries++; + }else{ + good_try[cpt] = guess; + cpt++; } } if (guessed_correctly == word_length) { printf("Félicitations ! Vous avez deviné le mot : %s\n", word); - save_party("Win", word, try); + save_party("Win", word, try, tries, good_try, cpt); } else { printf("Désolé, vous avez perdu. Le mot était : %s\n", word); display_hangman(MAX_TRIES); - save_party("Lose", word, try); + save_party("Lose", word, try, tries, good_try, cpt); } return 0; diff --git a/save_party.txt b/save_party.txt index 8175bdd1036832ad51c8982e8da2f544b6161057..2b1f2580f6c621d3879d94fa16504b209e8f1b78 100644 GIT binary patch literal 110 zcmYkyF%E+;3Y1v}9+MaDaMM}6yekWk245v?oZIu++z zAn%b2r^I