Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
eb15c18771 | ||
![]() |
02b4cb3b9b | ||
83de6ef49e | |||
![]() |
69a78a0776 | ||
![]() |
3c89c51854 | ||
![]() |
684ed5e821 |
@ -40,7 +40,7 @@ int main(int argc, char *argv[])
|
|||||||
// Check if all words were successfully placed
|
// Check if all words were successfully placed
|
||||||
// Start the game if successful
|
// Start the game if successful
|
||||||
// error message if some words couldn't be placed
|
// error message if some words couldn't be placed
|
||||||
|
printf("HAllo");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -8,5 +8,22 @@
|
|||||||
// Read words from file and store in 'words' array
|
// Read words from file and store in 'words' array
|
||||||
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
||||||
{
|
{
|
||||||
|
//Erstellt Pointer auf textdokument
|
||||||
|
FILE *textdokument = fopen("words.txt", "r");
|
||||||
|
if (file == NULL) {
|
||||||
|
printf("words,txt konnte nicht geoffnet werden");
|
||||||
|
}
|
||||||
|
// ToDo 2D char Array um wörter zu speichern kommt hier rein
|
||||||
|
char word[MAX_WORD_LEN];
|
||||||
|
unsigned int count = 0;
|
||||||
|
while (fscanf(textdokument, "%s", word) != EOF && count < maxWordCount) {
|
||||||
|
// Kopiere das gelesene Wort in das 2D-Array
|
||||||
|
strncpy(words[count], word, MAX_WORD_LEN - 1);
|
||||||
|
words[count][MAX_WORD_LEN - 1] = '\0'; // Sicherstellen, dass der String nullterminiert ist
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
fclose(textdokument);
|
||||||
|
return count;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user