generated from freudenreichan/info2Praktikum-Wortsalat
began developing concept for readWords
This commit is contained in:
parent
1affb13041
commit
46b6efbd69
@ -2,11 +2,13 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
static char *singleWordBuffer;
|
static char *buffer;
|
||||||
|
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
// eine Funktion implementieren, die ein einzelnes Wort aus einer Textdatei (words.txt) einliest und als C-String zurückgibt.
|
// eine Funktion implementieren, die ein einzelnes Wort aus einer Textdatei (words.txt) einliest und als C-String zurückgibt.
|
||||||
|
|
||||||
|
/*
|
||||||
char *readSingleWord(FILE *file)
|
char *readSingleWord(FILE *file)
|
||||||
{
|
{
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
@ -18,9 +20,29 @@ char *readSingleWord(FILE *file)
|
|||||||
fgets(singleWordBuffer, MAX_LINE_LEN, file);
|
fgets(singleWordBuffer, MAX_LINE_LEN, file);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
// Read words from file and store in 'words' array
|
// 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user