Compare commits
No commits in common. "main" and "main" have entirely different histories.
@ -40,7 +40,7 @@ int main(int argc, char *argv[])
|
||||
// Check if all words were successfully placed
|
||||
// Start the game if successful
|
||||
// error message if some words couldn't be placed
|
||||
printf("HAllo");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -8,22 +8,5 @@
|
||||
// Read words from file and store in 'words' array
|
||||
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
||||
{
|
||||
//Erstellt Pointer auf textdokument
|
||||
FILE *textdokument = fopen(file, "r");
|
||||
if (textdokument == NULL) {
|
||||
printf("Datei konnte nicht geoffnet werden");
|
||||
}
|
||||
// 2D char Array um wörter zu speichern
|
||||
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