Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Linked Lists question

This topic is 5579 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I use this structure: struct Thing { int ID,value; char *name; Thing *next; }; I also made a search function: Thing *Find(int searchID) { //for(current=head;current;current=current->next) current=head; while(current) { if(current->ID==searchID) { return current; } current=current->next; } return NULL; } and in the main function I use it like that: Thing *thing1=NULL; thing1=Find(2); if(thing1) { cout << thing1->value ; } But the result is always 0.I can''t find what''s wrong , please help me. Thanks in advance.

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
Maybe you''re not properly initializing head.

Do this to see what''s happening:

cout << current->ID << endl;

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!