generated from freudenreichan/info2Praktikum-Wortsalat
input fix strtok
This commit is contained in:
parent
3657ee5ff7
commit
19787739a7
@ -19,7 +19,7 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
||||
|
||||
while(fgets(puffer, MAX_LINE_LEN-1, file) != NULL && counter < maxWordCount)
|
||||
{
|
||||
char *parts = strtok(puffer, ",;/n/t. ");
|
||||
char *parts = strtok(puffer, ",;\n\t/. ");
|
||||
|
||||
while(parts != NULL && counter < maxWordCount)
|
||||
{
|
||||
@ -27,11 +27,18 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
||||
//words[counter][MAX_WORD_LEN-1] = "\0";
|
||||
//Großbuchstaben
|
||||
for(int i = 0; i < MAX_WORD_LEN -1 && parts[i] != '\0'; i++)
|
||||
{
|
||||
words[counter][i] = toupper(parts[i]);
|
||||
words[counter][i] = '\0';
|
||||
}
|
||||
}
|
||||
counter++;
|
||||
parts = strtok(NULL, ",;/n/t. ");
|
||||
counter++; // Wort eingelesen -> Wortzähler erhöhen
|
||||
parts = strtok(NULL, ",;\n\t/. ");
|
||||
|
||||
}
|
||||
return counter;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//TODO: Wörter auf Zahlen, Umlaute überprüfen -> ändern
|
||||
Loading…
x
Reference in New Issue
Block a user