Changing an individual character within a string
Posted on 2006-05-03
I've been struggling with this for a while. It's such a simple question that I've been reluctant to ask it.
How do you change an individual character within a string without replace or substring/remove in visual c++ .net?
The .net equivalent of :
st[index] = '\newvalue';
I have to use this method because the file I have a problem with needs extra carriage returns filtered out of it and the newline/carriage return's that are in the right place left alone.
I thought about this:
arbSt = mainSt->Substring(indexOfExtraCrLf - 10, 20); // arbitrary length to make sure replace doesn't replace everything
tmpSt = mainSt->Substring(beginning - 10, 20)->Replace("\r\n", " ");
That would work, but I'd rather know a better way so I don't end up doing that for every typo within my source file.