c - 制作链接列表

标签 c linked-list visual-studio-2012

typedef struct{
    char name[25];
    int yearOfBirth;
    int district;
    char gender;
    int age;

    CitizenType *next;

}CitizenType;

当我尝试在 Visual Studio 中创建这种格式的链接列表时,我收到各种与语法相关的错误。 (总共 102 个)但是当我注释掉 CitizenType *next;我没有收到任何错误。我意识到这与在完全声明结构之前引用结构有关,但我不知道如何解决这个问题。

最佳答案

在结构之前(并单独)声明 typedef。

typedef struct citizen_type CitizenType;

struct citizen_type {
    ...
    CitizenType *next;
};

关于c - 制作链接列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13215658/

相关文章:

c++ - C/C++ 中 unsigned 关键字的混淆

c++ - 定位/下载头文件 R.h 和 Rmath 用于 C 与 R 接口(interface)

java - 从Java中的列表中删除重复的对象

visual-studio-2012 - 在Windows Phone 8.0应用程序中选择手机而不是耳机的麦克风

C 程序在尝试使用套接字时输出奇怪的 "ur message"

c - 通过指针给变量赋值

Visual Studio 2012 中的 C# 6.0 支持

c++ - Visual C++ 2012 中的 getenv

c - Del. and r/w linked List Nodes in Multithreading with RW-locks -> 死锁?

java - 如何使用用户输入更改对象的名称?