I'm passing a text file to a function and want to extract each line of the text file into an array strCollect. I can compile with no errors and buff even returns the correct string for each line. But when it gets to the end of the text file the program crashes. After crashing: "Process Returned -1073741819 <0xC0000005>
void dataRead(FILE* inFile, char strCollect[DATAHOLD][SIZE],
int* buffCountP, int* curvTrackP, struct graph graph1 ){
while(!feof(inFile)) { //struct graph graph1;
fgets( buff, sizeof(buff), (FILE*) inFile);
strcpy(strCollect[buffCount-1], buff );
subString = strstr( strCollect[*buffCountP-1], "Title");
//
//if statements with substring
//
++buffCount;
}
*buffCountP = buffCount;
return;
}
//function prototype
void dataRead( FILE *inFile, char strCollect[DATAHOLD][SIZE],
int* buffCountP, int* curvTrackP, struct graph graph1);
//function call
dataRead(inFile, strCollect, *buffCountP, &curvTrackP, graph1);
I was under the impression that the while loop should terminate after the end of file has been reached but it appears that it doesn't identify the EOF.