我不知道为什么我们使用它来访问变量。有什么标准吗?如果有的话?
#include <stdio.h>
struct st {
int i;
char ch;
} s;
int main() {
s.i = 10;
printf("%d\n", s.i);
}
点运算符和箭头运算符不相同:
点运算符采用结构的属性。箭头运算符采用结构的属性,您正在使用的指针指向该结构。
These two lines are the same thing:
(*(*(*a).b).c).d
a->b->c->d
看起来似乎更实用,而且更好看,否则,您必须使用顶部的似乎很难阅读的那个,所以我们使用->运算符,因为它更简单。