Jump to content
  • Advertisement
Sign in to follow this  
31337noob

pointer problems

This topic is 4495 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

ok i have a pointer problem. i have a char **exception then i do exception= new char*[size] now, here is my problem. when i change one data element, all the data elements are changing. i tried exception[lines++]= (char*)&temp; but, that didnt work. it still changed all the data in the array to be the same thing. i only want to change the current element. thats in a for loop and temp is just a var that parses a file. i debuged it and temp is working correctly, but not the exception array. any ideas on how to change only the current element and not all the elements? thanks in advanced

Share this post


Link to post
Share on other sites
Advertisement
unsigned size = 12, lines = 0;
char *temp = "Dude";
char **exception;
exception = new char *[size];
exception[lines++] = temp;
That said, if using C++, you should use std::string + std::vector/std::list.


jfl.

Share this post


Link to post
Share on other sites
Quote:
Original post by jflanglois
unsigned size = 12, lines = 0;
char *temp = "Dude";
char **exception;
exception = new char *[size];
exception[lines++] = temp;
That said, if using C++, you should use std::string + std::vector/std::list.


jfl.


fine. i was hoping not to tough. i do love vectors, but i wanted to try to handle everything myself, but its complicated because pointers are hard to get used to.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!