generated from freudenreichan/info2Praktikum-Wortsalat
Final version
This commit is contained in:
1 parent
1b724bd972
commit
1e65abfe69
1 file changed
+7
-6
+7
-6
@@ -11,10 +11,10 @@ static int createSingleWords(char text[MAX_LINE_LEN], char words[][MAX_WORD_LEN]
|
||||
|
||||
unsigned int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
||||
{
|
||||
int wordCount = 0;
|
||||
char lineRead[MAX_LINE_LEN];
|
||||
unsigned int wordCount = 0; // Eingelesene Wörter
|
||||
char lineRead[MAX_LINE_LEN]; // Aktuell eingelesene Zeile
|
||||
|
||||
while(fgets(lineRead, MAX_LINE_LEN, file) != NULL && wordCount < (int)maxWordCount)
|
||||
while(fgets(lineRead, MAX_LINE_LEN, file) != NULL && wordCount < maxWordCount)
|
||||
{
|
||||
wordCount += createSingleWords(lineRead, words + wordCount, maxWordCount - wordCount);
|
||||
}
|
||||
@@ -27,16 +27,17 @@ static int createSingleWords(char text[MAX_LINE_LEN], char words[][MAX_WORD_LEN]
|
||||
char *teiler = " ;,.\r\n";
|
||||
char *token;
|
||||
|
||||
int i = 0;
|
||||
unsigned int i = 0;
|
||||
|
||||
token = strtok(text, teiler);
|
||||
|
||||
while(token != NULL && i < (int)maxWordCount)
|
||||
while(token != NULL && i < maxWordCount)
|
||||
{
|
||||
strncpy(words[i], token, MAX_WORD_LEN - 1);
|
||||
|
||||
//kleinbuchstaben --> GROßBUCHSTABEN
|
||||
int length = strlen(words[i]);
|
||||
for(int j = 0; j < length; j++)
|
||||
for(unsigned int j = 0; j < length; j++)
|
||||
{
|
||||
if(islower(words[i][j]))
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user