generated from freudenreichan/info2Praktikum-Wortsalat
endlosschleife behoben
This commit is contained in:
parent
85a79e9235
commit
16b0b9a450
@ -8,20 +8,22 @@
|
||||
// Read words from file and store in 'words' array
|
||||
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
||||
{
|
||||
|
||||
puts("....");
|
||||
char puffer[MAX_LINE_LEN]; //Array für eingelesene Zeile
|
||||
int counter = 0; //Zähler für Anzahl eingelesener Wörter
|
||||
int i;
|
||||
|
||||
while(fgets(puffer, MAX_LINE_LEN-1, file) != NULL && counter < maxWordCount)
|
||||
{
|
||||
puts(".!!!!!");
|
||||
char *word_parts = strtok(puffer, ",;\n\t/. "); //Wörter aufteilen
|
||||
|
||||
while(word_parts != NULL && counter < maxWordCount)
|
||||
{
|
||||
for(i = 0; i < MAX_WORD_LEN -1 && word_parts[i] != '\0'; i++)
|
||||
for(i = 0; i < MAX_WORD_LEN -1 || word_parts[i] != '\0'; i++)
|
||||
{
|
||||
words[counter][i] = toupper(word_parts[i]); //Großbuchstaben erzeugen
|
||||
puts("?????????????????");
|
||||
}
|
||||
words[counter][i] = '\0'; //Stringdefinition vervollständigen
|
||||
}
|
||||
|
||||
Binary file not shown.
BIN
Start_Windows/runTests.exe
Normal file
BIN
Start_Windows/runTests.exe
Normal file
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
|
||||
Loading…
x
Reference in New Issue
Block a user