2 Commits
Author SHA1 Message Date
Gade 1cb18630be Input Aufgaben bearbeitet 2026-10-27 21:51:27 +01:00
Gade 24466628da main.c ohne //a 2026-10-27 21:47:10 +01:00
2 changed files with 23 additions and 1 deletions

No files matched your search

+22
View File
@@ -8,5 +8,27 @@
// 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)
{ {
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;
} }
+1 -1
View File
@@ -10,7 +10,7 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int exitCode = EXIT_SUCCESS; int exitCode = EXIT_SUCCESS;
//a
// Check if the correct number of arguments is provided // Check if the correct number of arguments is provided
if(argc != 2) if(argc != 2)
{ {