How to read words from a text file and add to an array of strings?

前端 未结 2 2056
太阳男子
太阳男子 2021-01-16 07:17

Here is my function which is called with:getWord(words);

void getWord(char words[][MAXWORDLENGTH]){
int i;
char newWord[MAXWORDLENGTH];
FILE* fi         


        
2条回答
  •  萌比男神i
    2021-01-16 07:43

    Use fread() method

    while(fread(newWord, MAXWORDLENGTH,1,file)){
        printf("newWord: %s", newWord);
        strcpy(words[i], newWord);
    }
    

提交回复
热议问题