Browse Source

Commit 28 - func level_plus einbauen

remotes/origin/peter^2
Peter Wiebe 11 months ago
parent
commit
cfb70011a9
  1. 28
      src/main/c/hangman.c

28
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]); void show_letters(char secret_word[100], char guessed_letters[100]);
int letter_in_secret_word(char guessed_letter, char secret_word[100]); int letter_in_secret_word(char guessed_letter, char secret_word[100]);
int has_won(char secret_word[100], char guessed_letters[100]); int has_won(char secret_word[100], char guessed_letters[100]);
void level_plus();
void protokoll(){ void protokoll(){
clear_screen(); clear_screen();
@ -343,3 +344,30 @@ int has_won(char secret_word[100], char guessed_letters[100]){
} }
return 1; 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);
}
Loading…
Cancel
Save