Hey all,
I have a rather bad problem. I have just made my first real attempt at
creating a linked list, and am having problems adding an entry to it.
What happens when an entry is added, is that all previous entries are
over-written with the new entry, but then only the names themselves are
over-written, everything that is an integer remains the same.
So, I have done this:
struct player_index_element {
char *name;
int id;
struct player_index_element *next;
}
Then basically, did this:
void load_player_index(void)
{
struct player_index_element pie;
/* Open file stuff here -- This part is easy */
while (fscanf(index, "%s %s", name, idnum) != EOF) {
if (pie.name) {
free (pie.name);
pie.name = NULL;
}
pie.name = str_dup(name);
pie.id = atoi(idnum);
create_pfile_entry(&pie);
}
fclose(file);
}
void create_pfile_entry(struct player_index_element *pie)
{
struct player_index_element *pindex;
pie->next = NULL;
CREATE(pindex, struct player_index_element, 1);
*pindex = *pie;
pindex->next = player_table;
/* PROBLEM IS HERE, DON'T KNOW WHY */
player_table = pindex;
}
I have done extensive logs on it to track the problem down to where the
comment is, but I can go no further.
pindex->id copies over okay onto player_table, but all the names become
the last name on the list.
If any of you can help, I will forever be in your debt. :)
Rasdan
=--=--=--=--=--=--=--=--=--=--=
I have done so much,
with so little, James C. Thomas Jr.
for so long, Rasdan
That I can do anything Head Coder of Finality!
with nothing.
=--=--=--=--=--=--=--=--=--=--=
Finality is based upon CircleMUD 3.0, check us out:
finality.mudservices.com 5555
+------------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
| http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
+------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/08/00 PST