Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
struct new { struct A var1 ; struct B var2 ; }; struct new var3 ; struct new *var3ptr ; var3ptr = &var3 ; //assign the address to pointer.
如何使用指针 var3ptr 访问结构 A 的变量。
谢谢纳文
如果你的意思是去内部变量然后
var3ptr->var1; var3ptr->var2;
例如,如果
struct A { int x; }; struct B { int y; };
那么你可以做
printf("%d", var3ptr->var1.x); printf("%d", var3ptr->var2.y);