一个练习的总结
练习的目标:写一个程序,利用结构体建立一个数据库存放图书数据。下面是代码:
#include<stdio.h>
#include<stdlib.h>
struct Book
{
char title[120];
char author[40];
float price;
unsigned int date;
char publisher[40];
};
void initialize(struct Book *book)
{
printf("the name of the book:\n");
scanf("%s", book->title);
printf("the name of the author:\n");
scanf("%s", book->author);
printf("price:\n");
scanf("%f", &book->price);
printf("date:\n");
scanf("%d", &book->date);
printf("publisher:\n");
scanf("%s", book->publisher);
}
void show(struct Book *book)
{
printf("This is the confirm of the informations:\n");
printf("Name:%s\n", book->title);
printf("Athor:%s\n", book->author);
printf("Price:%.2f\n", book->price);
printf("Date:%d\n", book->date);
printf("Publisher:%