#include<stdio.h>
struct Date
{
int year;
int month;
int day;
};
struct Book
{
char title[128];
char author[40];
char price;
struct Date date;
char publisher;
};
struct Book getinput(struct Book book)
{
printf("书名:");
scanf_s("%s", book.title);
printf("作者:");
scanf_s("%s", book.author);
printf("价格:");
scanf_s("%f", book.price);
printf("出版日期:");
scanf_s("%d-%d-%d", book.date.year,book.date.month,book.date.day);
printf("出版社:");
scanf_s("%s", book.publisher);
return book;
}
void printBook(struct Book book)
{
printf("书名:%s\n", book.title);
printf("作者:%s\n", book.author);
printf("价格:%f\n", book.price);
printf("出版日期:%d-%d-%d\n", book.date.year,book.date.month,book.date.day);
printf("出版社:%s\n", book.publisher);
}
int main()
{
struct Book b1= {"xx","xx",0.0,0-0-0,"xx"},C;
printf("请输入第一本书的信息\n");
C=getinput(b1);
printBook(b1);
return 0;
}