I don't really know how to even begin solving this problem. Basically, I have a structure:
I want to fill out the fields of the structure...Code:struct Items{
char*desc;
char*name;
char*behave;
struct Areas*loc;
struct Items*next;
struct Items*prev;
USE_FUNCTION use;
};
The problem here is that when I assigned new->prev and new->next to NULL, the value of new->name changes! Apparently it is resetting the value to NULL. I'm not sure why at all, but it is causing segmentation faults.Code:fgets (input, 255, file); if ((p = strchr(input, '\n')) != NULL) *p = '\0';
new=createitem("NULL", "NULL", currentarea);
name=strtok(input,",");
desc=strtok(NULL, ",");
behavior=strtok(NULL, ",");
new->name=strdup(name);
new->desc=strdup(desc);
new->behave=strdup(behavior);
new->loc=&a[currentarea]; printf("%s", new->name);
new->prev=NULL; new->next=NULL; printf("%s", new->name);