Dylan Landrin add some comments
This commit is contained in:
parent
179c7b82c0
commit
fba618ec0e
17
pendu.c
17
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++;
|
||||
}
|
||||
}
|
||||
|
BIN
save_party.txt
BIN
save_party.txt
Binary file not shown.
Loading…
Reference in New Issue
Block a user