generated from freudenreichan/info2Praktikum-Wortsalat
added comments to input.c and tested the programm again
This commit is contained in:
parent
d00feb8401
commit
9ef55c581f
@ -32,8 +32,11 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
||||
|
||||
do
|
||||
{
|
||||
// get the next char from the file
|
||||
currentChar = fgetc(file);
|
||||
|
||||
// if current char is a capital letter
|
||||
// write it into the words array
|
||||
if ((currentChar >= 'A') && (currentChar <= 'Z'))
|
||||
{
|
||||
if (!currentlyInWord)
|
||||
@ -44,6 +47,9 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
||||
words[word][wordChar] = currentChar;
|
||||
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'))
|
||||
{
|
||||
if (!currentlyInWord)
|
||||
@ -54,6 +60,9 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
||||
words[word][wordChar] = toupper(currentChar);
|
||||
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)
|
||||
{
|
||||
words[word][wordChar] = '\0';
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user