Quote:
Originally Posted by magnus.therning
I found that the following code works:
int pos;
while((pos = my_string.find_first_of(" ")) != std::string::npos)
my_string[pos] = '_';
But, very C++ it isn't.
|
I'd say that this is far more 'C++' ..
std::string my_string("The quick brown fox jumped over the lazy dog");
std::replace( my_string.begin(), my_string.end(), 'o', '*' ); 