Input Aufgaben bearbeitet
This commit is contained in:
1 parent
24466628da
commit
1cb18630be
1 file changed
+22
@@ -8,5 +8,27 @@
|
||||
// Read words from file and store in 'words' array
|
||||
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
||||
{
|
||||
char line[MAX_LINE_LEN];
|
||||
int count = 0;
|
||||
|
||||
while (fgets(line, MAX_LINE_LEN, file) != NULL &&
|
||||
count < maxWordCount)
|
||||
{
|
||||
// Zeilenumbruch entfernen
|
||||
line[strcspn(line, "\n")] = '\0';
|
||||
|
||||
// Wort ins Array kopieren
|
||||
strncpy(words[count], line, MAX_WORD_LEN - 1);
|
||||
words[count][MAX_WORD_LEN - 1] = '\0';
|
||||
|
||||
// In Großbuchstaben umwandeln
|
||||
for (int i = 0; words[count][i] != '\0'; i++)
|
||||
{
|
||||
words[count][i] = toupper((unsigned char)words[count][i]);
|
||||
}
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
Reference in new issue
Block a user