C99 Structure Designated Initialisers and other value

后端 未结 3 1899
再見小時候
再見小時候 2021-01-17 11:06

I am aware that in C99 you can initialize members of the structure using member name as follows :

struct myStruct
{
 int i;
 char c;
 float f;
};
         


        
3条回答
  •  Happy的楠姐
    2021-01-17 11:28

    Here, 6 is non-designated initializer. So, this value is initialized to the member just after the previous designated initializer, that is the float just after char.

    In case you had two or more non-designated initializers in series, then the non-designated initializers would be initialized to the members in series from last designated initializer.

提交回复
热议问题