dev-landrin #6

Merged
Killian SCHIED merged 3 commits from dev-landrin into master 2024-10-15 12:04:08 +02:00
2 changed files with 8 additions and 9 deletions
Showing only changes of commit fba618ec0e - Show all commits

17
pendu.c
View File

@ -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++;
}
}

Binary file not shown.