search
尋找貓咪~QQ 地點 桃園市桃園區 Taoyuan , Taoyuan

[C/C++基礎]-雙層結構初始化 – jashliao部落格

[C/C++基礎]-雙層結構初始化

一般的C/C++講解結構(struct)大都只舉例一層的結構,但有時我們卻要使用多層的結構,因此今天和各位(C/P)程式同好介紹如何實現雙層結構初始化。

行號  程式 
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19

#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);
}

 

 





熱門推薦

本文由 jashliaoeuwordpress 提供 原文連結

寵物協尋 相信 終究能找到回家的路
寫了7763篇文章,獲得2次喜歡
留言回覆
回覆
精彩推薦