Hello all,
I have this struct:
typedef struct cell {
char _name[2];
int _calcResult;
int _depend[MAX_CELLS];
} Cell;
and this is my main:
int main(int argc, char* argv[]) {
FILE *fp;
int i;
fp=fopen(argv[1], "r");
Cell Cells[MAX_CELLS];
fillNames(fp,Cells);
for(i=0;i<4;i++)
printf("%s\n", Cells[i]->_name);
}
static void fillNames(FILE* fp, Cell *Cells) {
char line[2];
int i=0;
while(fgets(line, sizeof line, fp)!=NULL) {
strcpy(Cells[i]->_name, line);
i++;
}
}
Any help will be very appreciated!!
Thanks.
I have an array of structs and I'm trying to insert the first two chars from each line from the file into the _name field in the struct inside the array.
I get this message:
error: invalid type argument of ‘->’ (have ‘Cell’)