我在丹尼斯里奇那里找到了这个,
struct rect r , *rp = r;
那么这四个表达式是等价的:
r.pt1.x
rp->pt1.x
(r.pt1).x
(rp->pt1).x
因为运算符从左到右关联。
不应该是struct rect *rp = &r吗?
最佳答案
绝对——需要地址运算符,otherwise you get a compile-time error :
incompatible types when initializing type ‘struct rect *’ using type ‘struct rect’
关于c - 给指针赋值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16675860/