快速制作静态链表
Quickly make a static linked list
我想快速做一个静态链表,代码尽量少,可读性好,不乱。我如何优雅地完成此操作?
类似
1 -> 2 -> 3 -> 4 -> NULL
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))));
我想快速做一个静态链表,代码尽量少,可读性好,不乱。我如何优雅地完成此操作?
类似
1 -> 2 -> 3 -> 4 -> NULL
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))));