Well sounds like a job for void
Code:
struct node {
void *data;
struct node *next;
};
struct node *insertAtHead ( struct node *head, void *data ) {
struct node *new = malloc( sizeof *new );
new->data = data;
new->next = head;
return new;
}
Then you can do things like
Code:
struct node *list1 = NULL;
struct node *list2 = NULL;
list1 = insertAtHead( list1, &myint );
list2 = insertAtHead( list2, &mych );
But you do need to allocate space for your data in this example, though no doubt a more sophisticated implementation could take care of that.
The list implementation only ever has to deal with a void* pointer to the thing you want to store in the list, so it could be anything you want when you use the list.