forked from freudenreichan/info2Praktikum-Wortsalat
Entfernen von doppelter else func
This commit is contained in:
1 parent
6340b63273
commit
c2d35dfe89
2 files changed
+6
-16
No files matched your search
+3
-2
@@ -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++;
|
||||
}
|
||||
|
||||
|
||||
+3
-14
@@ -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;
|
||||
|
||||
@@ -46,16 +44,6 @@ int main(int argc, char *argv[])
|
||||
startGame(wordSalad, SALAD_SIZE, words, wordCount, 800);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Fehler beim Erstellen des Wortsalats
|
||||
fprintf(stderr,
|
||||
"Fehler beim Erstellen des Wortsalats. Rueckgabewert: %d\n",
|
||||
(int)placedWords);
|
||||
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]);
|
||||
@@ -65,3 +53,4 @@ int main(int argc, char *argv[])
|
||||
|
||||
return exitCode;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user