There are some weird symbols being printed while printing the desc string. I dont know what the problem is. Please review these code and let me know what i am doing wrong.
The code I am using to insert data into a Linked List.
void insert(string &name,string &desc,string &cat,string &date){
int count=0;
nn = new node;
if (head==NULL){
count++;
nn->count=count;
nn->hb_name= name;
nn->hb_desc= desc;
nn->category= cat;
nn->date= date;
nn->next=NULL;
head=nn;
}
else{
temp = head; // The temp points to the first node
while ( temp->next != NULL)
temp = temp->next;
temp1=temp; //temp1 is the last node
temp1->next = new node; // Creates a node at the end of the list
temp =temp1->next; // Points to that node
count++;
nn->count=count;
temp->hb_name= name;
temp->hb_desc= desc;
temp->category= cat;
temp->date= date;
temp->next = NULL;
free(temp1);
}
}
I am using the following code to print the above stuff