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)
|
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)
|
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";
|
//words[counter][MAX_WORD_LEN-1] = "\0";
|
||||||
//Großbuchstaben
|
//Großbuchstaben
|
||||||
for(int i = 0; i < MAX_WORD_LEN -1 && parts[i] != '\0'; i++)
|
for(int i = 0; i < MAX_WORD_LEN -1 && parts[i] != '\0'; i++)
|
||||||
|
{
|
||||||
words[counter][i] = toupper(parts[i]);
|
words[counter][i] = toupper(parts[i]);
|
||||||
|
words[counter][i] = '\0';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
counter++;
|
counter++; // Wort eingelesen -> Wortzähler erhöhen
|
||||||
parts = strtok(NULL, ",;/n/t. ");
|
parts = strtok(NULL, ",;\n\t/. ");
|
||||||
|
|
||||||
}
|
}
|
||||||
return counter;
|
return counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//TODO: Wörter auf Zahlen, Umlaute überprüfen -> ändern
|
||||||
Loading…
x
Reference in New Issue
Block a user