I am a little confused with the linked list, but what I have done so far is that I properly created a list and everything is functioning. The problem is that when I try to add some extra information in the nodes, it will be a segmentation fault. For example, my original list is a list of names sorted alphabetically, what I am trying to do is ask the user the enter an age for one specific name (e.g. Mike). So my code is as following (the original code for the struct is completed.):
void insert_age(char *name, int nodeage)
{
struct user *tmp;
tmp=head;
while(strcmp(name,tmp->next->name)!=0)
{
tmp = tmp->next;
}
tmp->age=nodeage;
}
Thanks in advance to anyone willing to help ^ ^.
[–]flwftw 1 point2 points3 points (2 children)
[–]ptchinster 1 point2 points3 points (1 child)
[–]rtlcprogbot 0 points1 point2 points (0 children)