Compare commits

..

3 Commits
main ... jonas

Author SHA1 Message Date
8d94db8e56 gitignore geändert 2025-10-19 14:32:34 +02:00
2895866ef0 input vervollständigt 2025-10-19 14:30:44 +02:00
0c0a0f39c2 gitignore erweitert 2025-10-17 21:56:40 +02:00
3 changed files with 28 additions and 0 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
I2_Wortsalat/Start_Mac/wordsalad_initial
I2_Wortsalat/Start_Mac/.DS_Store
I2_Wortsalat/.DS_Store

View File

@ -8,5 +8,30 @@
// Read words from file and store in 'words' array
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
{
char lines [1024]; //TODO: Sinnvolle Begrenzung finden
int word_counter = 0;
while (fgets(lines, sizeof(lines) , file) != NULL)
{
for (int i = 0; lines[i] != '\0'; i++) //Entfernen von \n aus dem String
{
if (lines[i] == '\n')
{
lines[i] = '\0';
break;
}
}
char *single_word = strtok(lines, " ;,");
while (single_word != NULL && word_counter < maxWordCount)
{
strncpy(words[word_counter], single_word, MAX_WORD_LEN - 1);
words [word_counter][MAX_WORD_LEN -1] = '\0'; //Zur Sicherheit, damit \0 auf alle Fälle vorhanden ist
word_counter++;
single_word = strtok(NULL, " ;,");
}
}
return word_counter;
}