Sign in to follow this  

pointer problems

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

This topic is 4283 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this