@2018-08-29
【小记】
结构体多维数组成员初始化的方法以及赋值内容的表示方法
1 #include2 3 4 typedef struct TTSET 5 { 6 char ssTime[3][2][6]; //start-stop time 7 char time[6][6]; 8 char time0[6][6]; 9 unsigned char enbaleOpt1:1;10 unsigned char enbaleOpt2:1;11 unsigned char enbaleOpt3:1;12 }TTSET_s;13 14 15 int main()16 {17 int i, j;18 19 TTSET_s obj = 20 {21 ssTime:{ { { "08:00"}, { "12:00"}}, { { "14:00"}, { "17:00"}}, { { "20:00"}, { "24:00"}}},22 time:{ { "08:00"}, { "12:00"}, { "14:00"}, { "17:00"}, { "20:00"}, { "24:00"}},23 time0:{ "08:00", "12:00", "14:00", "17:00", "20:00", "24:00"},24 enbaleOpt1:0,25 enbaleOpt2:0,26 enbaleOpt3:027 };28 29 for(i =0; i < 3; i++)30 for(j =0; j < 2; j++)31 printf("%s\t", obj.ssTime[i][j]);32 printf("\n");33 34 for(i =0; i < 6; i++) 35 printf("%s\t", obj.time[i]);36 printf("\n");37 38 for(i =0; i < 6; i++) 39 printf("%s\t", obj.time0[i]);40 printf("\n");41 }