Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
C++ split string.. For example if I had doctorMMMwhoMMM. How to get rid of MMM and get Doctor who?
using a delimiter
1 Answer
- MaynLv 57 years agoFavorite Answer
This should work:
string inString = "doctorMMMwhoMMM";
string myString = "doctorwho";
string newString;
char delimiter = 'M';
for (int i=0; i < inString.length(); i++)
{
if (inString[i] != delimiter)
newString = newString + inString[i];
}
cout << newString << endl;
If you want "doctor who" then there should be a space in inString otherwise it will be a bit more complicated.