I am trying to use the CString.replace method and seem to not be replacing the rest of the string.
tmpStr.Replace(_T('in.'), _T(' ')); is the specific line. I want to remove all instances of the string "in." in the CString tmpStr. But it seems it only to replace the 'i' in "in." with a space. And the rest it leave alone.
Is there a way to replace a string with a string?
1 Answer
You're not calling the overload that you intend to call. CString::Replace has an overload that takes two characters, that's the one your function call invokes. Change 'in.' to "in." (note the double quotes instead of single quotes). Similarly, change ' ' to " ".
'in.' is a multicharacter literal, and how this is interpreted is implementation defined. It seems VC just considers it to be the same as i.