typedef struct 和struct
1.typedef struct:
struct Books
{
char title[50];
char author[50];
char subject[100];
int book_id;
} book;
例如:
typedef struct {
char title[50];
char author[50];
int book_id;
} Books;
Books myBook;
2. struct:
struct tag {
member-list
member-list
member-list
...
} variable-list ;
例如:
struct Books {
char title[50];
char author[50];
int book_id;
};
struct Books myBook;
当然,初始化时,也可以直接
struct Books {
char title[50];
char author[50];
int book_id;
}abc;不用再单独的 struct Books abc;
N:strcpy函数:把字符串赋值给结构体变量
注意指针*和地址符& !!! 2024-03-12