Sign in to follow this  
31337noob

pointer problems

Recommended Posts

31337noob    101
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
jflanglois    1020
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
31337noob    101
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

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