我想初始化 mainstr 的所有三个数组,谁能帮我在结构内初始化这个匿名联合?第 0 个索引应该用整数数组初始化,第 1 个和第 2 个索引用字符指针初始化。
typedef struct
{
int testy;
union
{
int a[3];
char* b[3];
}
bool testz;
} testStr;
typedef struct
{
testStr x[3];
} mainStr;
像这样的东西,
mainStr test = {
{20, {{10, 20, 30}}, FALSE},
{10, {{"test1", "test2", NULL}}, TRUE},
{30, {{"test3", "test4", NULL}}, FALSE},
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句