鱼C论坛

 找回密码
 立即注册
查看: 1941|回复: 2

求助

[复制链接]
发表于 2019-12-2 22:14:59 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
各位大佬,这是跟着视频敲得代码,但是编译的时候出错了。因为刚刚开始学,所以看不懂哪里出错了,或者哪里敲错了。请各位前辈指点一下。谢谢
# include <stdio.h>
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 getInput (struct Book book);
void printBook (struct Book book);
struct Book getInput (struct Book book)
{
        printf ("请输入书名:");
        scanf ("%s",book.title);
        printf ("请输入作者:");
        scanf ("%s",book.author);
        printf ("请输入售价:");
        scanf ("%f",&book.price);
        printf ("请输入出版日期:");
        scanf ("%d-%d-%d",&book.date.year,&book.date.month,&book.date.day);
        printf ("请输入出版社:");
        scanf ("%s",book.publisher);
        return book;
}
void printBook (struct Book book)
{
        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);
}
int main (void)
{
        struct Book b1, b2;
        printf ("请录入第一本书的信息...\n");
        b1 = getInput(b1);
        putchar('\n');
        printf ("请录入第二本书的信息...\n");
        b2 = getInput(b2);

        printf ("\n\n录入完毕,现在开始打印验证...\n\n");
        printf ("打印第一本书的信息...");
        printBook(b1);
        putchar ('\n');
        printf ("打印第二本书的信息...");
        printBook(b2);
        return 0 ;
}
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2019-12-2 22:20:15 | 显示全部楼层
struct Book
{
        char title[128];
        char author[40];
        float price;
        struct Date date;
        char publisher[40];
};
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-12-2 22:32:40 | 显示全部楼层
ba21 发表于 2019-12-2 22:20
struct Book
{
        char title[128];

谢谢
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-10-5 01:23

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表