uppercase fixed

This commit is contained in:
Simon 2025-10-25 17:50:41 +02:00
parent 30ef5e53f5
commit ad88cbbba6

View File

@ -13,7 +13,7 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
char *token; char *token;
file = fopen("words.txt", "r"); file = fopen("words.txt", "r");
if(file == NULL) if (file == NULL)
{ {
printf("\nNot able to open file.\n"); printf("\nNot able to open file.\n");
fclose(file); fclose(file);
@ -29,14 +29,21 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
while (token != NULL) while (token != NULL)
{ {
strncpy(words[n], token, MAX_WORD_LEN); strncpy(words[n], token, MAX_WORD_LEN);
char *s = words[n];
while (*s)
{
*s = toupper((unsigned char)*s);
s++;
}
// printf("Einzelwort: %s\n", words[n]); // printf("Einzelwort: %s\n", words[n]);
token = strtok(NULL, teiler); token = strtok(NULL, teiler);
n++; n++;
} }
} }
fclose(file); fclose(file);
return 0; return n;
} }