Zi 字媒體
2017-07-25T20:27:27+00:00
[C/C++基礎]-雙層結構初始化
一般的C/C++講解結構(struct)大都只舉例一層的結構,但有時我們卻要使用多層的結構,因此今天和各位(C/P)程式同好介紹如何實現雙層結構初始化。
行號
程式
01020304050607080910111213141516171819
#include
struct child{ int a; float b;};struct father{ int a; float b; child ch1;};//fa1={10,20.0f,{30,40.0}};main(){ father fa1={10,20.0f,{30,40.0}}; printf(“%d\t%f\n”,fa1.ch1.a,fa1.ch1.b); printf(“%d\t%f\n”,fa1.a,fa1.b);}
寫了
5860316篇文章,獲得
23313次喜歡