c - Can a linked list node contain more than one data field? -


i'm rather asking if makes sense this. have not seen examples of haven't seen goes against idea.

i in publisher-subscriber model, idea have far is: create list of topics, added file.

but instead of having each name of topic , pointer next topic, kind of wanted have node of suscribers each topic, in each topic's node.

since i'm explaining myself poorly, idea:

struct topicnode{ char * topicname; //i believe there no problem pointers in lists again, have not seen doing either so...  struct suscribernode; struct topicnode next; }; 

and make, if there's suscriber topic, list of suscribers topic. i've done similar things in java, i'm worried it's not such idea in c.

yes, single linked list can contain data

------------------------------              ------------------------------ |              |             |            \ |              |             | |     data     |     next    |--------------|     data     |     next    | |              |             |            / |              |             | ------------------------------              ------------------------------ 

ref : http://www.learn-c.org/en/linked_lists

data can int, struct, really. 2 fields or 3 or 4 or ....

typedef struct node {     int val;     struct node * next; } node_t; 

is classic example

typedef struct node {     int val;     int anotherval;     struct node * next; } node_t; 

is good. val , anotherval belong data in picture , said can anything.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -