hey i have a file that i need to read and then store into an array.
the file is called ass2.txt and looks like this:
Code:
7453842
Gregory Harrison
4
CSCI104 0 56
IACT111 0 44
INFO112 0 75
CSCI321 0 89
7545349
Quentin Resnick
3
CSCI104 0 55
IACT101 1 76
INFO101 0 78
there are two records in the file as seen above i need to read the records one by one and then store them into an array called gRecs[].
this is only part of my code that i have so far to read the file:
Code:
bool ReadFile()
{
FILE *openfile;
openfile=fopen(ass2.txt,"r");
/*Checks if file exists, removing auto generated file if not*/
if (openfile == NULL){
fprintf(stderr,"Error Opening %s",ass2.txt);
remove(ass2.txt);
return false;
}
/*store records in array*/
while(fscanf(open file, "%s", gRecs){
fclose(openfile);
return true;
im not sure if this is the correct way any help would be appreciated cheers.