generated from freudenreichan/info2Praktikum-Wortsalat
24 lines
689 B
C
24 lines
689 B
C
#include "input.h"
|
|
#include <string.h>
|
|
#include <ctype.h>
|
|
|
|
// TODO:
|
|
// eine Funktion implementieren, die ein einzelnes Wort aus einer Textdatei (words.txt) einliest und als C-String zurückgibt.
|
|
|
|
// Read words from file and store in 'words' array
|
|
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
|
{
|
|
char word[MAX_WORD_LEN];
|
|
|
|
// we possibly don't need fopen, since file is already a parameter
|
|
// fopen(stream)
|
|
|
|
fgets(word, MAX_WORD_LEN,file);
|
|
// fgets(string, length, file *stream)
|
|
|
|
strcpy(words[maxWordCount-1], word);
|
|
maxWordCount++;
|
|
// we possibly also won't need to close the
|
|
// fclose( *<stream>)
|
|
return 0;
|
|
} |