This is usually done using void pointers:
typedef struct node { struct node *next; void *data; } node; node *insert(node *list, void *data) { } node *delete(node *list, node *to_delete) { }
such manipulation functions are independent of the actual data type; therefore, they can be implemented as a whole. For example, you might have a data type structure for the data field above:
typedef struct data { int type; void *data; } data; data d; d.type = INT; d.data = malloc(sizeof(int)); node n = {NULL, (void*)&data);
perreal
source share