alekq
alekq

Reputation: 137

c++ array of pointer to string and append() method

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.

Upvotes: 0

Views: 326

Answers (1)

alekq
alekq

Reputation: 137

thank to @user4581301 , the solution is

std::string *part [n];

std::string h = object1.getText().substr(0,5) 
array[0] = &h;

std::string hh = object1.getText().substr(6);
array[0]->append(hh);

Upvotes: 1

Related Questions