How to replace a period ( dot ' . ' ) with a space

Hi everyone,

I have a string that has a period at the end and i want to replace that period with a space.

How do you do that?

Thanks in advance
After

1
2
3
4
#include <string>
...
string str = "How to replace a period ( dot ' . ' ) with a space.";
...


you could use

 
str.replace(str.end()-1,str.end()," ");


or

1
2
size_t found = str.find_last_of(".");
str.replace(found,1," ");


More in: http://www.cplusplus.com/reference/string/string/
1
2
3
4
string s="you don't care."
cout<<s;//prints 'you don't care.'
string s="you don't care "
cout<<s;//prints 'you don't care ' e is followed by char(32) 
Topic archived. No new replies allowed.