Server Help

General Questions - Delete Funcation!

Versetti - Fri Jan 09, 2004 9:22 pm
Post subject: Delete Funcation!
I'm trying too make a Link List for my Msg Board thingy and I need too know how too delete like a user entry out of my link list let me show you the link list that I'm work with:
Code: Show/Hide

class boardUdata{
public:
   int UserID;
   char Name[32];
   char Email[100];
   char Sig[256];
   char title[32];
   int posts;
   int warnlevel;
   int Level;
   bool banned;
   bool limitread;
   boardUdata* Next;
};

and I want too be able too have it search the Name Var in the list and then delete that whole entry that the name is found in. I hope you undestand what I just said because I'm kinda tired so I'm just typing.
Cyan~Fire - Fri Jan 09, 2004 11:13 pm
Post subject:
Why don't you just use the ANSI list datatype?
Anonymous - Sat Jan 10, 2004 3:58 pm
Post subject:
Do a strcmp() on the Name of every link until you get a match. Lets say the matching link is 'foo' and the previous link is 'bar', then:
Code: Show/Hide
bar->Next = foo->Next;
free(foo);

Versetti - Sun Jan 11, 2004 9:32 pm
Post subject:
Cyan~Fire wrote:
Why don't you just use the ANSI list datatype?


I nevered used it but if it is a better way I would.
Cyan~Fire - Mon Jan 12, 2004 5:39 pm
Post subject:
Well ANSI C++ has a built in linked list. It's pretty useful (dunno why Catid didn't use it in MERVbot).

Check out the MSDN library page on it.
Versetti - Mon Jan 12, 2004 9:17 pm
Post subject:
ARGH I think this means I have too remake just about the whole Database part!!!!

..............I thought there was a stupid delete thingy that I can code into a funcation that will work :-I .......... Grrrrr

that MSDN does not explain it too good. O well gr.
ExplodyThingy - Mon Jan 12, 2004 9:38 pm
Post subject:
The delete thingy needs to get the previous item in the list and point it to the next tiem. You need to do this->last->next=next; and this->next->last=last; in order to point around the old node. Then simply delete it.
Cyan~Fire - Tue Jan 13, 2004 5:30 pm
Post subject:
Lol well you don't have to use it if you don't want to, I was just suggestion a pre-made one to help you out icon_razz.gif
Mine GO BOOM - Wed Jan 14, 2004 10:26 am
Post subject:
Remember, if you create the link via new, you'll need to free it via delete. If you create it via malloc, you'll need to free it via free. Don't mix the two methods.
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group