Lets say the list contains these: (format : First Name, Last Name, Birthdate, Gender, Status)
John,Doe,1/1/1990,m,I love burgers!
James,Dean,2/3/1867,m,I need some action!
Marilyn,Monroe,5/9/1825,f,I need some rest!
Then I have this structure
Expand|Select|Wrap|Line Numbers
- typedef struct _node_t {
- Item iData;
- struct _node_t *pNext;
- } node_t
Expand|Select|Wrap|Line Numbers
- typedef struct {
- char *first_name;
- char *last_name;
- char *birthdate;
- char sex;
- char *status
- } Item;
but I'm having a problem with storing them into the linked list. I get a segmentation fault everytime.
I'm supposed to have these ff functions:
Expand|Select|Wrap|Line Numbers
- node_t * createNode(Item iData) {
- /*
- Missing Code must:
- Allocate new node
- Set data member
- Set next member
- Return new node
- */
- }
- void insertNode(node_t * pHead, Item iData)
- {
- node_t *pNew;
- node_t *pCur;
- pCur = pHead;
- pNew = createNode(iData);
- /*
- Missing Code must:
- Insert the created node into a linked list
- */
- }
Expand|Select|Wrap|Line Numbers
- int main (void){
- node_t head;
- head.pNext = NULL;
- //Other Variable Declarations
- .
- .
- .
- //PARSING CODE HERE
- //After parsing and storing the parsed data into the structure Item
- insertNode(&head, iData);
- }
can you suggest some codes for the said functions??
Thanks in advance!