在下面的代码中,如何创建指向变量triangle.pluto.mars.a的指针,因此在printf行中不必为成员a重复整个路径。
#include <stdio.h>
int main(){
struct euler {
int a;
int b;
};
struct gauss {
int f;
int g;
struct euler mars;
};
struct aristotle{
int x;
int y;
struct gauss pluto;
} triangle;
triangle.pluto.mars.a = 151;
printf("\nThe value is: %d\n\n",triangle.pluto.mars.a );
return 0;
}
最佳答案
创可贴解决方案:
int * someVariable = &(triangle.pluto.mars.a);
长期的解决方案:重新设计。
关于c - 如何在C中的嵌套结构中创建指向变量的指针?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31416730/