c - 这就是我在链表中​​创建链表的方式吗?

标签 c types struct linked-list

嗯,我的项目要求我在链接列表中创建一个链接列表。我这样定义可以吗?

struct users {
  int user_ID;

  struct playlist{
    int album;
    int track_num;
    struct playlist *next;
  }

  struct users *next;
};

最佳答案

为什么不将结构分开?

struct Playlist{
    int album;
    int track_num;
    struct Playlist *next;
}


struct users {
  int user_ID;

  struct Playlist playlist 
  struct users *next;
};

它更容易阅读,更容易理解。

关于c - 这就是我在链表中​​创建链表的方式吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9944113/

相关文章:

c - 你如何在 C 中将 char* 转换为 int 或 double

swift - 为什么函数不被视为命名类型?

C:我将如何编写搜索函数来在结构数组中查找匹配项,并返回(打印)它匹配的整个结构?

C typedef结构的不确定性

c - C中链表的两个结构

无法通过函数返回值打印字符串?

c - 为解析器编写规则

c - FFTW 库 : verifying fourier transform derivative property

python - 如何让 PyC​​harm 从函数定义中获取类型提示并在文档字符串中填充类型值?

scala - Scala中的现有类型