Would this be ok?
Code:
#include <stdio.h>
#define MAXRECORDS 4
struct record
{
char gender;
int age;
int lead;
};
void readfile();
void main()
{
struct records rec[MAXRECORDS];
readfile();
}
void readfile()
{
FILE *fpin;
fpin = fopen("custsurvey.dat", "r");
if(fpin == NULL)
{
printf("Error opening file");
}
else
{
while(!feof(fpin))
{
for(i = 0; i < MAXRECORDS; i++)
fscanf(fpin, "%c %d %d", &rec[i].gender, &rec[i].age, &rec[i].lead));
}
}
fclose(fpin);
}
And also how would I pass the pointer to the function? Just unsure how I would with the code I have.