I want to have array of pointers to strings.
std::string *part [n];
I also have object witch has method that return string,
let's name it:
object1.getText();
when I want to get part of the string to array's element it's not a problem:
std::string h = object1.getText().substr(0,5)
array[0] = &h;
but how can I append some text to existing element?
something I've tried:
std::string hh = object1.getText().substr(6)
array[0].append(&hh);
didn't work.
array[0] = &object1.getText().substr(0,5);thestringreturned bysubstrdoes not last long enough for a pointer to it to be meaningful.std::string::appendhas no overload that accepts a pointer to astring.array[0].append(...)should bearray[0]->append(...)becausearray [0]is a pointer. I recommend going over the section on pointer syntax in your text book again and working through some of the examples.