sh!t your right, I should have initialized the prev to NULL to use for the head....
sorry for the frustration..
sh!t your right, I should have initialized the prev to NULL to use for the head....
sorry for the frustration..
Wouldn't list->foot need to be updated even in situations where it's non-NULL? [I'm assuming "foot" is equivalent of "tail" in this case, rather than for example "the first inserted element", as the latter isn't a particularly useful concept as far as I'm aware.
I think the expresson shoudl be "if(curr == NULL)" instead, but I'm not 100% sure. Can you confirm, iMalc?
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
yeh, foot/tail needs to be updated, but so what? it was the algorithm i was looking for... the proccess... of course His program needs to be updated, but really...
He doesn't care and doesn't think about it so anal....
so what do you recommend? code wise?
Last edited by qubit67; 09-07-2007 at 04:56 AM.
Well, if the algorithm is "broken", it needs to be fixed, otherwise it's wrong. You'll find that A LOT of us here are anal about getting things right, because there are lots of things that are wrong. If you fix theintoCode:if (list->foot == NULL) list->foot = ins;then you should be fine. Yes, it's anal, but it's "necessary" to get it right, assuming you do use foot for some purpose.Code:if (curr == NULL) list->foot = ins;
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.