我有這樣的:如何在C中訪問數組中的特定結構?
typedef struct{
field_1;
field 2;
.....
}student;
typedef struct{
student record[100];
int counter;
}List;
然後我想添加每個「學生」的信息,例如:
List *p;
gets(p->list[index]->field_1);
但是當我編譯它拋出此代碼:
[Error] base operand of '->' has non-pointer type 'student'
那麼爲什麼我不能指向'列表'和訪問'列表'中特定「記錄」的方式?
使用'.'操作者而不是' - >'(第二個).. –
或者complentarty創建指針學生的陣列。 – hetepeperfan