So I have a string which contains "RGGB"
and I need it to be in a char
array to perform some operations. Then I need to replace certain characters for a blank space, for example the first 'G'
, so that my char
array remains "R GB"
.
How can I do this? So far I tried this solution:
int main()
{
string problem="RGGB";
const char *p=problem.c_str();
p[1]=' ';
return p;
}
I get the error:
assignment of read only location
*(p + ((sizetype)i))