In the example below Im trying to add 2 strings to the array. Whenever I overwrite the "TestText" it changes the ones in the array also....
Does the array only old a pointer to the original string ? so in effect am I pushing a pointer to the var TestText ?
In which case how do I push the contents of the string ?
Code: Select all
irr::core::array<char *> TestArray;
char TestText[] = "POS1";
char TestText2[] = "POS2";
TestArray.push_back(TestText); // push POS1
strcpy(TestText, TestText2); // copy POS2 over POS1
TestArray.push_back(TestText); // push POS2
printf("1 = %s \n", TestArray[0]); // this says POS2
printf("2 = %s \n", TestArray[1]); // and this also says POS2