Reading each line of file into array

后端 未结 2 525
误落风尘
误落风尘 2020-12-19 11:44

I\'m reading a file and want to put each line into a string in an array. The length of the file is arbitrary and the length of each line is arbitrary (albeit assume it will

2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-19 11:59

    You should change the line:

    char** words = (**char)malloc(sizeof(*char));
    

    into this:

    char** words=(char **)malloc(sizeof(char *)*Max_Lines);
    

提交回复
热议问题