diff --git a/src/main/c/hangman.c b/src/main/c/hangman.c index d20711d..037c170 100644 --- a/src/main/c/hangman.c +++ b/src/main/c/hangman.c @@ -21,6 +21,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(); @@ -342,4 +343,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