|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
请问 这个结构体数组应该怎么打印,printf怎么输出
- #include<stdio.h>
- int i;
- struct Date
- {
- int year;
- int month;
- int day;
- };
- struct Book
- {
- char title[128];
- char author[40];
- float price;
- struct Date date;
- char publisher[40];
- };struct Book book[3]={
- {
- "<带你学c带你飞>",
- "小甲鱼",
- 48.8,
- {2017,11,11},
- "清华大学出版社"
- },
- {
- "<带你学c带你飞>",
- "小甲鱼",
- 48.8,
- {2017,11,11},
- "清华大学出版社"
- },
- {"<带你学c带你飞>",
- "小甲鱼",
- 48.8,
- {2017,11,11},
- "清华大学出版社"
- }
- };
- int main (void)
- {
-
- printf("书名:%s\n",book.title);
- printf("作者:%s\n",book.author);
- printf("售价:%.2f\n",book.price);
- printf("出版日期:%d-%d-%d\n",book.date.year,book.date.month,book.date.day);
- printf("出版社:%s\n",book.publisher);
- return 0;
- }
复制代码
|
|