i have in existing source base, linked list implementation(adding node, insertion, deletion , traversal) following structure:
typedef struct tagdirinfo { char *pdirname; struct tagdirinfo *__next; struct tagdirinfo *__prev; }dir_header;
lets assume char* pdirname points data part want form wrap data part , reuse existing apis , that, new linked list structure has data part as:
typedef struct printjob { char labelname[buf_len]; int pristatus; time_t time_stamp; }printjob;
i think if like:
printjob newjob; /* fill in newjob structure */ dir_header *newnode; newnode->pdirname = (char*)newjob; newnode->__next = null; newnode->__prev = null;
doing so, fill in linked list structure.
but how can access labelname data field through pdirname field of linked list structure?
do mean want :
printf("labelname : %s\n", ((printjob *)(newnode->pdirname))->labelname);
however, code have 1 mistake! correct it:
change
newnode->pdirname = (char*)newjob;
to
newnode->pdirname = (char*)&newjob;
Comments
Post a Comment