问题
I want to quickly make a static linked list, with as little code as possible, which is very readable and without clutter. How do i accomplish this elegantly?
something like
1 -> 2 -> 3 -> 4 -> NULL
回答1:
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))));
来源:https://stackoverflow.com/questions/29192284/quickly-make-a-static-linked-list