struct Apartment {
int floor; // aparment's floor
};
void main() {
Apartment apartments[10];// array containing all the apartments
create_apartments(apartments);
};
void create_apartments(struct Apartment *apartments) {
int i,pos;
pos=0;
for(i=0;i<10;i++){
*(apartments+pos)->floor = i; //error apears here!
pos++;
}
}
一元'*'(包含'int')的无效类型参数出现在注释行中。谁能告诉我有什么问题?谢谢:))
答案 0 :(得分:2)
->
运算符已取消引用指针。再次应用*
会尝试取消引用类型为(apartments+pos)->floor
的{{1}}。删除int
。
编辑:只写这个更为常见:
*