I want to change a C++ string at a particular index like this:
string s = \"abc\"; s[1] = \'a\';
Is the following code valid? Is this an a
Yes the code you have written is valid. You can also try:
string num; cin>>num; num.at(1)='a'; cout<
the std::replace can also be used to replace the charecter. Here is the reference link http://www.cplusplus.com/reference/string/string/replace/
Hope this helps.