input . c erster test
This commit is contained in:
parent
df39903293
commit
6654f3340a
@ -6,7 +6,7 @@
|
|||||||
// 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.
|
||||||
|
|
||||||
// Read words from file and store in 'words' array
|
// Read words from file and store in 'words' array
|
||||||
// f gets ; komma und semikolon erkennen und alles in groß buchstaben (=uppercase) (strtok)
|
|
||||||
int readWords(FILE* file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
int readWords(FILE* file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
||||||
{
|
{
|
||||||
char delimiter[] = ", ; \n";
|
char delimiter[] = ", ; \n";
|
||||||
@ -30,7 +30,7 @@ int readWords(FILE* file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
|||||||
while (token != NULL && count < maxWordCount)
|
while (token != NULL && count < maxWordCount)
|
||||||
{
|
{
|
||||||
for (char* p = token; *p; ++p)
|
for (char* p = token; *p; ++p)
|
||||||
*p=(char)toupper((unsigned char)*p);
|
(char)toupper((unsigned char)*p);
|
||||||
strncpy(words[count], token, MAX_WORD_LEN - 1);
|
strncpy(words[count], token, MAX_WORD_LEN - 1);
|
||||||
words[count][MAX_WORD_LEN - 1] = '\0';
|
words[count][MAX_WORD_LEN - 1] = '\0';
|
||||||
count++;
|
count++;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user