Hello, so I am trying to insert the character, which i got from a string, to another string. Here I my actions: 1. I want to use simple:
someString.insert(somePosition, myChar);
2. I got an error, because insert requires(in my case) char* or string
3. I am converting char to char* via stringstream:
stringstream conversion;
char* myCharInsert;
conversion << myChar //That is actually someAnotherString.at(someOtherPosition) if that matters;
conversion >> myCharInsert;
someString.insert(somePosition, myCharInsert);
4. Everything seems to be compiling successfully, but program crashes the gets to
conversion >> myCharInsert;
line.
5.I am trying to replace char* with string:
stringstream conversion;
char* myCharInsert;
conversion << myChar //That is actually someAnotherString.at(someOtherPosition) if that matters;
conversion >> myCharInsert;
someString.insert(somePosition, myCharInsert);
Everything seems to be OK, but when someAnotherString.at(someOtherPosition)
becomes space, program crashes.
So how do I correctly do this?