Memory refrence error when printing linked list

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Oct 2006
Posts: 164
Reputation: Barefootsanders is an unknown quantity at this point 
Solved Threads: 3
Barefootsanders Barefootsanders is offline Offline
Junior Poster

Memory refrence error when printing linked list

 
0
  #1
Nov 28th, 2007
I have a doubly linked list and I know it gets created with the proper values. For some reason when I run through my print function it, only prints 1/2 of the list and then gives me this:

the instruction at "0x7c93426d" referenced memory at "0x00000000". the memory could not be "read".

I'm assuming it's trying to reference a NULL pointer but I dont know how 1/2 the list gets printed and the other 1/2 all of a sudden is NULL. Are there any common problems associated with printing linked lists like this?

Thanks
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 164
Reputation: Barefootsanders is an unknown quantity at this point 
Solved Threads: 3
Barefootsanders Barefootsanders is offline Offline
Junior Poster

Re: Memory refrence error when printing linked list

 
0
  #2
Nov 28th, 2007
Also, btw, when I change the number of elements in the list and attempt to print that it works.. strange.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Memory refrence error when printing linked list

 
0
  #3
Nov 29th, 2007
Post the code which
- creates nodes
- adds them to the list
- prints the list.

There's nothing strange when it's implemented correctly, so I'm just going with there are bugs in your code.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 164
Reputation: Barefootsanders is an unknown quantity at this point 
Solved Threads: 3
Barefootsanders Barefootsanders is offline Offline
Junior Poster

Re: Memory refrence error when printing linked list

 
0
  #4
Nov 29th, 2007
Hey sorry. You were right and I was implementing it incorrectly. I was passing a NULL pointer to my print function and it crashed. Thanks for the input.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC