I'm trying to create a linked list with structs..for example
struct LL {
char data;
LL *next;
LL *prev;
}*test;
and then I want to create a function to add a new "list" to it. Like update the next...so I do this:
LL *UpdateLL(char what)
{
LL *updatee;
updatee->data = what;
test->next = updatee;
return test;
}
But it doesn't do it! I just changes ALL the 'data' to what ever the 'what' was. What I am I doing wrong? Please help!
Dare wa neko o koroshiteimasuka? (Ha! Learn Nihongo!)
Edited by - sponge99 on 6/4/00 5:29:12 PM
Linked Lists Problems
The "updatee" pointer is unknown.
You have to locate your mem dynamicly (new, malloc, LocalAlloc)
Try something like this:
Don''t forget to free the mem when you''re done (delete, free, LocalFree);
You have to locate your mem dynamicly (new, malloc, LocalAlloc)
Try something like this:
LL *UpdateLL(char what){LL *updatee;updatee = malloc(sizeof(LL));updatee->data = what;test->next = updatee;return test;}
Don''t forget to free the mem when you''re done (delete, free, LocalFree);
June 04, 2000 05:32 PM
1) When UpdateLL(char what); returns, LL *updatee is deallocated.
2) I don''t understand: "It just changes ALL the ''data'' to what ever the ''what'' was."
2) I don''t understand: "It just changes ALL the ''data'' to what ever the ''what'' was."
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement