数组作为结构体成员的初始化示例:
#include <stdio.h>
#include <stdlib.h>
typedef struct Month
{
unsigned char a[3];
unsigned char b[3];
}p_month;
void main()
{
p_month temp = {{1,2},{3,4,5}};
printf("temp.a[0] = %d,temp.a[1] = %d,.temp.a[2] = %d\n", temp.a[0], temp.a[1], temp.a[2]);
printf("temp.b[0] = %d,temp.b[1] = %d,temp.b[2] = %d\n", temp.b[0], temp.b[1], temp.b[2]);
system("pause");
}
运行结果:
temp.a[0] = 1,temp.a[1] = 2,.temp.a[2] = 0
temp.b[0] = 3,temp.b[1] = 4,temp.b[2] = 5
————————
2019.05.14
23:18