[英]C How can I acces struct members of a struct that is part of a struct array in another struct?
[英]How to get struct array (or pointer) that is part of another struct? in C
在以下代码中:
typedef struct
{
uint32_t variable_1;
}struct_1;
typedef struct
{
uint32_t variable_2;
}struct_2;
typedef struct
{
struct_1 struct_1_var;
struct_2 struct_2_var;
}struct_all;
struct_all variable_t[10];
struct_1* struct_1_var; //how to get this to point to an array of struct_1 that's inside variable_t?
基本上,我想获得一个 struct_1[10] 或 struct_2[10],它是 variable_t[10] 的一部分。
你不能,因为没有任数组struct_1
S或struct_2
S IN variable_t
来点。 有一个元素数组,每个元素都有一个struct_1
和一个struct_2
。
如果您只需要一个包含variable_t
其他值的一种类型的数组,则需要一次将它们一个复制到一个新数组中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.