I'm getting a strange error and I'm not sure why. I am attempted to scan from a txt file to a struct array and I am getting an error. It expects a ']' after SIZE even though I have a closing bracket for the array length.
Heres the snippet of code that the error is happening in. I am brand new to learning structures so if anything is wrong other than the initial question, please let me know.
Here is the struct definition:
struct employData{
char first[7];
char initial[1];
char last[9];
char street[16];
char city[11];
char state[2];
char zip[5];
int age;
char sex[1];
int tenure;
double salary;
};
and then here is the scan function that is not working:
int readData(employData){
int i = 0;
struct employData dataArray[SIZE];
fp = fopen("payfile.txt", "r");
if (fp != NULL){
printf("File opened. Scanning...");
while (!(feof(fp))){
fp = fscanf(fp, "%s %s %s %s %s %s %s %s %d %s %d %lf", dataArray[i].first, dataArray[i].initial, dataArray[i].last, dataArray[i].street, dataArray[i].city, dataArray[i].first, dataArray[i].state, dataArray[i].zip, dataArray[i].age, dataArray[i].sex, dataArray[i].tenure, dataArray[i].salary);
i++;
}
}
else {
printf("File open failed.");
}
}
Thanks!
Edit: Fixed blatant error. Still having intellisense error