From ab24d1d021e67b6ab2d7e17101a0ef0365f87e2e Mon Sep 17 00:00:00 2001 From: Peter Wiebe Date: Tue, 6 Feb 2024 18:49:35 +0100 Subject: [PATCH] Commit 28 - func level_plus einbauen --- src/main/c/hangman.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index 77be75b..333cc1c 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -20,6 +20,7 @@ void lade_secret_word(char* secret_word, int level, char* path); void show_letters(char secret_word[100], char guessed_letters[100]); int letter_in_secret_word(char guessed_letter, char secret_word[100]); int has_won(char secret_word[100], char guessed_letters[100]); +void level_plus(); void protokoll(){ clear_screen(); @@ -341,4 +342,31 @@ int has_won(char secret_word[100], char guessed_letters[100]){ } } return 1; +} + +void level_plus(){ + char KonfDatei[100]; + char levelstr[3]; + int i = 0; + + FILE *fp = NULL; + fp = fopen("hangman.txt", "r+"); + fscanf(fp, "%s", KonfDatei); + + while(KonfDatei[i] != 0){ + i++; + } + levelstr[0] = KonfDatei[i-2]; + levelstr[1] = KonfDatei[i-1]; + levelstr[2] = '\0'; + if (levelstr[1] == '9'){ + KonfDatei[i-2]++; + KonfDatei[i-1] = '0'; + } else { + KonfDatei[i-1]++; + } + fclose(fp); + fp = fopen("hangman.txt", "w"); + fprintf(fp, "%s", KonfDatei); + fclose(fp); } \ No newline at end of file