Use*_*ser 1 c struct declaration definition
struct Books
{
char title[50];
char author[50];
char subject[100];
int book_id;
} book;
Run Code Online (Sandbox Code Playgroud)
最后的“书”到底是什么?
它是一个类型struct Books
为 name的结构实例的声明book
。
它相当于
struct Books
{
char title[50];
char author[50];
char subject[100];
int book_id;
};
struct Books book;
Run Code Online (Sandbox Code Playgroud)
考虑到一般声明看起来像(简化形式)
type-sepcifier identifier;
Run Code Online (Sandbox Code Playgroud)
其中 identifier 是某个声明符。例如
int x;
Run Code Online (Sandbox Code Playgroud)
结构定义也属于类型说明符。
所以你可以写例如
struct A { int x; } s;
Run Code Online (Sandbox Code Playgroud)