Skip to content

Instantly share code, notes, and snippets.

@bwedding
Created February 19, 2018 07:06
Show Gist options
  • Save bwedding/fe91767b8a680196ef9f38231b4d49df to your computer and use it in GitHub Desktop.
Save bwedding/fe91767b8a680196ef9f38231b4d49df to your computer and use it in GitHub Desktop.
void CPPReplace(std::string &data)
{
const std::string s = ",";
const std::string t = ",\n";
std::string newString = "";
std::string::size_type n = 0;
/////////////
size_t loc = 0;
size_t start = 0;
while(1)
{
if (std::string::npos != (loc = data.find(",", start)))
{
newString += data.substr(start, (loc - start) + 1);
newString += "\n";
start = loc + 1; // skip the comma
}
else
break;
}
data = newString;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment