diff --git a/pendu.c b/pendu.c index 7bf2146..c6032b4 100644 --- a/pendu.c +++ b/pendu.c @@ -36,11 +36,12 @@ void display_hangman(int tries) { } /* -this function allow to save a last party +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 */ void save_party(char * status, const char * good_word, char try[]) { time_t t; @@ -48,10 +49,6 @@ void save_party(char * status, const char * good_word, char try[]) { char * date; date = ctime(&t); //stock the current time format as: day, month, number of the month, hour, year - /* for (int i = 0; i < sizeof(try); i++) { - printf("%c",try[i]); - }*/ - FILE* fichier = fopen("save_party.txt", "w"); if (fichier != NULL) @@ -68,11 +65,11 @@ void save_party(char * status, const char * good_word, char try[]) { fputs(good_word,fichier); fputs("\n",fichier); - /*fputs("tried letters: ", fichier); + fputs("tried letters: ", fichier); for (int i = 0; i < sizeof(try); i++) { - fputs(try[i],fichier); + fputc(try[i],fichier); } - fputc("\n",fichier);*/ + fputs("\n",fichier); fclose(fichier); // On ferme le fichier qui a été ouvert } @@ -100,7 +97,7 @@ int main() { printf("Entrez une lettre : "); scanf(" %c", &guess); - try[tries] = guess; + int found = 0; @@ -109,12 +106,14 @@ int main() { if (guessed[i] == '_') { guessed[i] = guess; guessed_correctly++; + try[tries] = guess; } found = 1; } } if (!found) { + try[tries] = guess; tries++; } } diff --git a/save_party.txt b/save_party.txt index 797beb6..8175bdd 100644 Binary files a/save_party.txt and b/save_party.txt differ