Compare commits

..

6 Commits
main ... main

Author SHA1 Message Date
Björn
eb15c18771 ToDo 2D char Array 2025-10-22 18:11:46 +02:00
Björn
02b4cb3b9b Merge branch 'main' of https://git.efi.th-nuernberg.de/gitea/turtschinba100320/info2Praktikum-WortsalatBasti 2025-10-22 17:59:52 +02:00
83de6ef49e merge upstream 2025-10-22 15:59:23 +00:00
Björn
69a78a0776 test 2025-10-22 17:37:45 +02:00
Bastian
3c89c51854 Pointer auf Textdokument erzeugt 2025-10-22 15:07:46 +02:00
Bastian~
684ed5e821 Test 2025-10-14 15:07:46 +02:00
2 changed files with 18 additions and 1 deletions

View File

@ -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
{ {

View File

@ -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;
} }