快速制作静态链表

tom*_*mol -2 c linked-list

我想快速创建一个静态链表,尽可能少的代码,这是非常可读,没有混乱.我如何优雅地完成这项工作?

就像是

1 -> 2 -> 3 -> 4 -> NULL

Arj*_*ran 8

struct node {int x; struct node *next;};
#define cons(x,next) (struct node[]){{x,next}}
struct node *head = cons(1, cons(2, cons(3, cons(4, NULL))));
Run Code Online (Sandbox Code Playgroud)

  • `cons`?真棒! (2认同)