input . c erster test

This commit is contained in:
Luis Gessnitzer 2025-11-04 10:48:06 +01:00
parent df39903293
commit 6654f3340a

View File

@ -6,7 +6,7 @@
// eine Funktion implementieren, die ein einzelnes Wort aus einer Textdatei (words.txt) einliest und als C-String zurückgibt.
// Read words from file and store in 'words' array
// f gets ; komma und semikolon erkennen und alles in groß buchstaben (=uppercase) (strtok)
int readWords(FILE* file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
{
char delimiter[] = ", ; \n";
@ -30,7 +30,7 @@ int readWords(FILE* file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
while (token != NULL && count < maxWordCount)
{
for (char* p = token; *p; ++p)
*p=(char)toupper((unsigned char)*p);
(char)toupper((unsigned char)*p);
strncpy(words[count], token, MAX_WORD_LEN - 1);
words[count][MAX_WORD_LEN - 1] = '\0';
count++;