generated from freudenreichan/info2Praktikum-Wortsalat
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7f0f3ceeb9 | |||
| 9ef55c581f | |||
| d00feb8401 | |||
| b26202cd9b | |||
| 25a13b1dca | |||
| 398936b789 | |||
| cba52d17c5 |
@ -32,8 +32,11 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
// get the next char from the file
|
||||||
currentChar = fgetc(file);
|
currentChar = fgetc(file);
|
||||||
|
|
||||||
|
// if current char is a capital letter
|
||||||
|
// write it into the words array
|
||||||
if ((currentChar >= 'A') && (currentChar <= 'Z'))
|
if ((currentChar >= 'A') && (currentChar <= 'Z'))
|
||||||
{
|
{
|
||||||
if (!currentlyInWord)
|
if (!currentlyInWord)
|
||||||
@ -44,6 +47,9 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
|||||||
words[word][wordChar] = currentChar;
|
words[word][wordChar] = currentChar;
|
||||||
wordChar++;
|
wordChar++;
|
||||||
}
|
}
|
||||||
|
// if the current char is a lowercase letter
|
||||||
|
// change it to its capital version
|
||||||
|
// and write it into the words array
|
||||||
else if ((currentChar >= 'a') && (currentChar <= 'z'))
|
else if ((currentChar >= 'a') && (currentChar <= 'z'))
|
||||||
{
|
{
|
||||||
if (!currentlyInWord)
|
if (!currentlyInWord)
|
||||||
@ -54,6 +60,9 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
|||||||
words[word][wordChar] = toupper(currentChar);
|
words[word][wordChar] = toupper(currentChar);
|
||||||
wordChar++;
|
wordChar++;
|
||||||
}
|
}
|
||||||
|
// if the current char is NOT a letter
|
||||||
|
// the end of a word has been reached
|
||||||
|
// skip chars untill a new letter is found
|
||||||
else if (currentlyInWord)
|
else if (currentlyInWord)
|
||||||
{
|
{
|
||||||
words[word][wordChar] = '\0';
|
words[word][wordChar] = '\0';
|
||||||
@ -63,7 +72,6 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
|||||||
}
|
}
|
||||||
|
|
||||||
} while (((currentChar != EOF) && (word <= maxWordCount)));
|
} while (((currentChar != EOF) && (word <= maxWordCount)));
|
||||||
printf("wortzahl: %d\n", word);
|
|
||||||
|
|
||||||
return word;
|
return word;
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
1
Start_Windows/testwords_delims.txt
Normal file
1
Start_Windows/testwords_delims.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
Hund,Katze; Maus
|
||||||
0
Start_Windows/testwords_empty.txt
Normal file
0
Start_Windows/testwords_empty.txt
Normal file
3
Start_Windows/testwords_simple.txt
Normal file
3
Start_Windows/testwords_simple.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Apfel
|
||||||
|
Banane
|
||||||
|
Kiwi
|
||||||
BIN
Start_Windows/wordsalad.exe
Normal file
BIN
Start_Windows/wordsalad.exe
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user