Welcome to Gaia! ::


Tipsy Bloodsucker

8,125 Points
  • Forum Regular 100
  • Nerd 50
  • Invisibility 100
Hi, so I made a program that implements doubly linked lists and have insert and delete functions. My delete functions which is suppose to delete at locations specified by an int typed index doesn't seem to be working.
here's that part of the code:

here


and this is the errors that it shows User Image

and here is the entire source code:
source code

8,950 Points
  • Gaian 50
  • Member 100
  • Contributor 150
In general, 'variable' is a horrible name to use for any identifier.

Why does 'delete_after' take both a value and a location as arguments? Are you deleting by value or deleting by location? (Or both?!?)

Look at the first error you're receiving. The part it doesn't like is 'temp->variable', which means the member named 'variable' of the structure that 'temp' points to.

What type of structure does 'temp' point to?
What are the names of the members of that structure?
Is 'variable' one of them?
Yeah, your call to temp->variable should be temp->forward or temp->backward.

So much about this function is wrong ...
For example, why are you inserting a value in the delete function when the head is NULL? If the head is null you should simply return or throw an error. But calling a "delete" function and ending up with more than you started with is counter intuitive.

Wait, did you just copy "insert_after" and make a few adjustments?

Quick Reply

Submit
Manage Your Items
Other Stuff
Get GCash
Offers
Get Items
More Items
Where Everyone Hangs Out
Other Community Areas
Virtual Spaces
Fun Stuff
Gaia's Games
Mini-Games
Play with GCash
Play with Platinum