Suppose s structure function is defined as:
I need to write a function void insert_queue( queue **q_front, queue **q_rear, char *str, char str_num[]), such that *q_front point to the 1st node, *q_rear point to the last node. It adds new node with name str and phone str_num at the end queue while updating q_rear and q_front.Code:typedef struct node { char *name; char phone[9]; struct node *next; } queue;
I came out with the below definition but the program don't work. Hope anyone can spot my error. Thanks
Code:void insert_queue( queue **q_front, queue **q_rear, char *str, char str_num[]){ * q_front= (queue*) malloc(sizeof (struct node)); * q_front-> name= *str; * q_front-> phone= str_num; * q_front-> next= NULL; if (*q_rear !=NULL) *q_rear->next=*q_front; *q_rear= *q_front; return *q_rear; }



LinkBack URL
About LinkBacks


