I am doing a program which parses/separates a list of facebook friends' comma-separated data then stores them into a linked list.
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
where iData consists of
Then I have a working code for separating the data to first name, last name, etc
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:
such that in my main program
can you suggest some codes for the said functions??
Thanks in advance!
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
Code:
typedef struct _node_t {
Item iData;
struct _node_t *pNext;
} node_t
Code:
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:
Code:
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
*/
}
Code:
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!
Comment