Entfernen von doppelter else func

This commit is contained in:
hruschkajo103995 committed 2026-10-28 22:20:01 +01:00
1 parent 6340b63273
commit c2d35dfe89
2 files changed
+9 -19

No files matched your search

+3 -2
View File
@@ -23,7 +23,8 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN],
char *word = strtok(line, " ,;\n\t\r");
while (word != NULL && wordCount < maxWordCount) {
while (word != NULL && wordCount < maxWordCount)
{
strncpy(words[wordCount], word, MAX_WORD_LEN - 1);
words[wordCount][MAX_WORD_LEN - 1] = '\0';
@@ -31,7 +32,7 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN],
while (words[wordCount][i] != '\0') {
words[wordCount][i] =
(char)toupper((unsigned char)words[wordCount][i]);
(char)toupper((unsigned char)words[wordCount][i]);// char davor da toupper einen int wert liefert und einen unsigned char bekommt
i++;
}
+6 -17
View File
@@ -9,8 +9,7 @@
#define MAX_NUMBER_OF_WORDS 100
#define SALAD_SIZE 20
int main(int argc, char *argv[])
{
int main(int argc, char *argv[]) {
int exitCode = EXIT_SUCCESS;
srand(time(NULL)); //Seed für Zufallszahlen
@@ -21,8 +20,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "Usage: %s <path to file with search words>\n", argv[0]);
exitCode = EXIT_FAILURE;
}
else
{
else {
char words[MAX_NUMBER_OF_WORDS][MAX_WORD_LEN]; // Array to hold the words to be used in the game
unsigned int wordCount = 0;
@@ -47,21 +45,12 @@ int main(int argc, char *argv[])
}
else
{
// Fehler beim Erstellen des Wortsalats
fprintf(stderr,
"Fehler beim Erstellen des Wortsalats. Rueckgabewert: %d\n",
(int)placedWords);
// Print error message if file couldn't be opened
fprintf(stderr, "Could not open file %s for reading ...\n", argv[1]);
exitCode = EXIT_FAILURE;
}
}
}
else
{
// Print error message if file couldn't be opened
fprintf(stderr, "Could not open file %s for reading ...\n", argv[1]);
exitCode = EXIT_FAILURE;
}
return exitCode;
}
return exitCode;
}