将指针放在数据结构之后有什么意义?

what the point of putting pointer after data structure?

我是 C 编程新手,刚学过结构体。我的问题是在定义结构之后放置指针有什么意义?就像这个例子(顺便说一句,这是我的高级代码):

struct lecturer { 
    char Lecturer_ID[40];
    char Lecturer_Passport[40];
    char Lecturer_Name[40];
    char Lecturer_Password[40];
    struct lecturer *next; 
} *start, *curr;

这与主题'Linked List'相关。

假设您有未知数量的讲师,这些讲师将在运行时提供给您。因此,每次需要处理新的讲师记录时,您都必须在内存中动态分配 space。

在这种情况下,您将使用 'next' 指针在这些相同类型的结构化数据之间创建 link。

不过,您可以在此站点或 youtube 等中找到更多详细(和更好)的解释。只需搜索 "Linked List"

您发布的代码同时定义了类型 struct lecturer 和 2 个变量 startcurr 以及指向 struct lecturer 的类型指针。为了清楚起见,这可以写成单独的定义:

struct lecturer { 
    char Lecturer_ID[40];
    char Lecturer_Passport[40];
    char Lecturer_Name[40];
    char Lecturer_Password[40];
    struct lecturer *next; 
};

struct lecturer *start;
struct lecturer *curr;

如果 struct 未标记且未通过 typedef 定义,则需要组合定义。