Skip to main content
gamedev.net
🔒 Locked

pointer problems

Started by 31337noob 1 reply 350+ views
Original Post
31337noob
31337noob
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
jflanglois
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.
31337noob
31337noob
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.