I'm not too experienced with C, and I am having a problem with strings/pointers that I can't figure out. in limits.c, this is part of the function set_title : void set_title(struct char_data * ch, char *title) { if (title == NULL) { title = READ_TITLE(ch); if ((GET_CLASS(ch) == CLASS_PALADIN) && (GET_LEVEL(ch) == 10) /* this next line causes the Segmentation fault */ strcat(title, "some string"); /* "some string" is actually a macro that returns a string, but I tested the macro independently and it works fine */ } /* if the 'if (GET_CLASS)...' check above fails, it makes it here fine */ if (strlen(title) > MAX_TITLE_LENGTH) title[MAX_TITLE_LENGTH] = '\0'; if (GET_TITLE(ch) != NULL) free(GET_TITLE(ch)); GET_TITLE(ch) = str_dup(title); /* this might be some clue to my misuse of title or strcat() */ } I kinda have an idea of why its crashing, but I can't really tell exactly why. I get the feeling that if I learn the solution to this problem it will be a big step in my understanding of pointers... Thanks in advance for your help! Steve
This archive was generated by hypermail 2b30 : 12/18/00 PST