I am trying to traversing an array into struct in C, but I got the error: error: expected identifier befoe '(' token
My Structs
typedef struct book {
int book_code;
char title[80];
char author[80];
InfoStudent status[2];
} Book;
typedef struct info_student {
char status_char;
char student_code[7];
int day_get;
int month_get;
int day_dev;
int month_dev;
} InfoStudent;
My function to save the data with error:
void create_book(Book *pbk) {
pbk->book_code= 1;
printf("Type the title:");
gets(pbk->title);
fflush(stdin);
printf("Type the author:");
gets(pbk->author);
fflush(stdin);
int i;
for (i=0; i<2; i++) {
pbk->(status+i)->day_get = -1; // Error line
pbk->(status+i)->day_dev = -1;
pbk->(status+i)->month_get = -1;
pbk->(status+i)->month_dev = -1;
pbk->(status+i)->student_code = '';
pbk->(status+i)->status_char ='F';
}
}
I am trying to set the status+0 values and status+1 values, using this for loop to optimize my writing code. I don't want use the "[" "]" to access the values.