began developing concept for readWords

This commit is contained in:
Jonas Hofmann 2025-10-31 01:50:00 +01:00
parent 1affb13041
commit 46b6efbd69

View File

@ -2,11 +2,13 @@
#include <string.h>
#include <ctype.h>
static char *singleWordBuffer;
static char *buffer;
// TODO:
// eine Funktion implementieren, die ein einzelnes Wort aus einer Textdatei (words.txt) einliest und als C-String zurückgibt.
/*
char *readSingleWord(FILE *file)
{
if (file == NULL)
@ -18,9 +20,29 @@ char *readSingleWord(FILE *file)
fgets(singleWordBuffer, MAX_LINE_LEN, file);
}
*/
// Read words from file and store in 'words' array
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
{
int i = 0;
int numberOfReadWords = 0;
char currentChar = 0;
do
{
fgetc(file + i);
i++;
} while (currentChar != EOF);
return numberOfReadWords;
}
/*