/*
============================================================================
Name : struct_arr_init.c
Author :
Version :
Copyright : Your copyright notice
Description : Hello World in C, Ansi-style
参考:https://blog.csdn.net/subfate/article/details/52776674
============================================================================
*/
#include <stdio.h>
#include <stdlib.h>
typedef enum
{
ZERO,
ONE,
TWO
}num_t;
typedef enum
{
FIRST,
SECOND
}type_t;
typedef struct _struct
{
num_t num;
type_t type;
}test_t;
int main(void) {
puts("!!!Hello World!!!"); /* prints !!!Hello World!!! */
test_t arr[3] =
{
[0] = {ZERO,FIRST},
[2] = {TWO,SECOND},
[1] = {ONE,SECOND}
};
test_t arr1[3] =
{
{ZERO,FIRST},
{TWO,SECOND},
{ONE,SECOND}
};
printf("arr[2] = %d\n",arr[2].num);
printf("arr1[2] = %d\n",arr1[2].num);
return EXIT_SUCCESS;
}