用c语言编写一个结构体,要求如下:设计一个图书馆信息结构体,包括有,书号,书名,作者,出版社,出版日期,
时间: 2024-05-09 08:15:03 浏览: 13
以下是一个用C语言编写的图书馆信息结构体示例:
```c
#include <stdio.h>
struct library {
int book_id;
char book_name[50];
char author[50];
char publisher[50];
char publish_date[20];
};
int main() {
struct library book1 = {1, "C Programming Language", "Brian Kernighan and Dennis Ritchie", "Prentice Hall", "February 22, 1988"};
printf("Book ID: %d\n", book1.book_id);
printf("Book Name: %s\n", book1.book_name);
printf("Author: %s\n", book1.author);
printf("Publisher: %s\n", book1.publisher);
printf("Publish Date: %s\n", book1.publish_date);
return 0;
}
```
输出结果为:
```
Book ID: 1
Book Name: C Programming Language
Author: Brian Kernighan and Dennis Ritchie
Publisher: Prentice Hall
Publish Date: February 22, 1988
```