Reading from text file to array help please!
-I've been able to get my program to work for just the first word in the file. But I want to create a loop for all of the words until end of file. But now I'm getting a segmentation fault. PLEASE HELP! I don't know how to get my program to work for all of them...
char getData(FILE* fp)
int i, j;
*list = (char *)malloc(MAXFILESIZE * sizeof(char));
if(*list == NULL)
printf("NOT ENOUGH MEMORY!\n");
for(i = 0; i < MAXFILESIZE; i++)
while(fscanf(fp, "%[^ ' ' ^ \n]", temp[i++])!=EOF)
if(ispunct(temp[strlen(temp) - 1 ]))
(temp[strlen(temp) - 1]) = '\0';
for(i = 0; i < strlen(temp); i++)
temp[i] = tolower(temp[i]);
-Also, I have to use fscanf, its for an assignment. But yes, I realize that there are other functions that would make this easier.
Thank you in advance.