## 第14章 结构和其他数据形式 14.5 嵌套结构 顶原

idreamo

``````//friend.c  --嵌套结构的例子
#include <stdio.h>
#define LEN 20
const char *msgs[5]=
{
"  Thank you for the wonderful evening,",
"You certainly prove that a ",
"is a special kind of guy. We must get together",
"over a delicious ",
" and have a few laughs"
};
struct names {
char first[LEN];
char last[LEN];
};
struct guy {
struct names handle;
char favfood[LEN];
char job[LEN];
float income;
};
int main(void)
{
struct guy fellow={
{"Ewen","Villard"},
"grilled salmon",
"personality coach",
58112.00
};

printf("Dear %s, \n\n",fellow.handle.first);
printf("%s%s.\n",msgs[0],fellow.handle.first);
printf("%s%s\n",msgs[1],fellow.job);
printf("%s\n",msgs[2]);
printf("%s%s%s",msgs[3],fellow.favfood,msgs[4]);
if(fellow.income>150000.0)
puts("!!");
else if(fellow.income>75000.0)
puts("!");
else
puts(".");
printf("\n%40s%s\n"," ","see you soon, ");
printf("%40s%s\n"," ","shalala");
return 0;
}
``````

struct names handle;

printf{"Hello,%s!\n",fellow.handle.first};

### idreamo

zting科技
2017/12/11
0
0

tony关东升
2016/02/24
0
0

2016/03/11
43
0

tony关东升
2018/06/26
0
0

2018/06/05
0
0

west_coast
13分钟前
1
0
spring boot入门，看这篇文章就够了

18分钟前
2
0
solidity智能合约implicit conversion异常

20分钟前
0
0
Null value appeared in non-nullable field java.lang.NullPointerException

26分钟前
0
0
【百度飞浆AI Studio】2、感性快速体验深度学习的线性归回预测房价

-个俗人
26分钟前
0
0