|
|
@ -16,6 +16,7 @@ void hauptSpiel(int level); |
|
|
|
void draw_hangman(int attempts); |
|
|
|
void add_guessed_letter(char* guessed_letters, char guessed_letter); |
|
|
|
char eingabe_buchstabe(); |
|
|
|
void lade_secret_word(char* secret_word, int level, char* path); |
|
|
|
|
|
|
|
void protokoll(){ |
|
|
|
clear_screen(); |
|
|
@ -267,4 +268,27 @@ char eingabe_buchstabe(){ |
|
|
|
scanf(" %c", &guess); |
|
|
|
guess = tolower(guess); |
|
|
|
return guess; |
|
|
|
} |
|
|
|
|
|
|
|
void lade_secret_word(char* secret_word, int level, char* path){ |
|
|
|
FILE *file = fopen(path, "r"); |
|
|
|
int count = 0; |
|
|
|
if ( file != NULL ) |
|
|
|
{ |
|
|
|
char line[100]; /* or other suitable maximum line size */ |
|
|
|
while (fgets(line, sizeof line, file) != NULL) /* read a line */ |
|
|
|
{ |
|
|
|
if (count == level) |
|
|
|
{ |
|
|
|
strcpy(secret_word, line); |
|
|
|
secret_word[strlen(secret_word) - 1] = '\0'; |
|
|
|
return; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
count++; |
|
|
|
} |
|
|
|
} |
|
|
|
fclose(file); |
|
|
|
} |
|
|
|
} |