c - 结构 - 声明说明符中的两个或多个数据类型(我有分号)

标签 c struct

不太确定是什么导致了这个问题,我在谷歌上发现的是,在我的结构末尾忘记了分号会导致这个问题,但我那里有一个。

这是代码块...

#include <stdio.h>
#include <string.h>

#define NAME_LENGTH 20
#define BOOK_NAME_LEN 50
#define AUTHOR_NAME_LEN 30
enum bookStatus {CHECKED_IN, CHECKED_OUT, UNDER_REPAIR, LOST}
enum patronStatus {ACTIVE, INACTIVE}
struct Book{
        char title[BOOK_NAME_LEN];
        char author[AUTHOR_NAME_LEN];
        enum bookStatus status;
};
struct Name{
        char first[NAME_LENGTH];
        char last[NAME_LENGTH];
};
struct Patron{
        int numBooksOut;
        struct Name name;
        struct Book books[50];
        enum patronStatus status;
};
struct Collection{
        struct Book book;
        char title[BOOK_NAME_LEN];
        char author[AUTHOR_NAME_LEN];
        int id, year;
        enum bookStatus status;
};
struct Library{
        int totalPatrons, totalBooks;
        struct Patron patrons[50];
        struct Collection collection[50];
};

最佳答案

枚举也需要分号。

关于c - 结构 - 声明说明符中的两个或多个数据类型(我有分号),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7829115/

相关文章:

c - 传递一维数组、二维数组和指针数组

c++ - 通过头文件 C++ 使用多个结构

c - 在C中的/bin和/sbin中查找Argv[i]

python - 涓滴单元测试

c++ - 使用结构体、函数和指针,我尝试将以下 C++ 代码转换为 C,但它不起作用

arrays - 在由可变结构元素组成的数组中的数据中使用 findmin() - Julia

ios - 动态结构变量名称

c - 如何在不同的 if 语句中访问我的结构的元素?

在 C 中创建和打印基于指针的结构

c - 为什么在调用 execvp() 时不能使用 char **myargs 而不是 char *myargs[3]?