this is my first time using structure within a structure.
I encounter this error when I compile my program.
error: field ‘results’ has incomplete type.
The error is referring to this line of code.
–>struct result_t results;
Any help please? 🙂
Thanks.
typedef struct {
char moduleCode[8];
char grade[3];
} result_t;
typedef struct {
char name[31];
struct result_t results;
} student_t;
Edit:
I changed my codes:
typedef struct {
char moduleCode[8];
char grade[3];
} result_t;
typedef struct {
char name[31];
result_t results;
} student_t;
and I got a new compilation error.
error : subscripted value is neither array nor pointer.
The line of code that triggered that error is as follows.
printf(” %-7s %-2s %d\n”, student.results[i].module_code, student.results[i].grade, student.results[i].mc);
Result is not an array. you should either change the structure student with:
Or change the printf to:
It depends on how many possible results one student may have.