Last active
January 1, 2021 22:56
-
-
Save VadokDev/4ec7aa489e55e45f2678f829bc4a2815 to your computer and use it in GitHub Desktop.
Un mini "split" que recibe un string y un delimitador de 1 sólo caracter y retorna un vector con cada una de las palabras obtenidas, no es de mi autoría, lo saqué de alguna respuesta de StackOverflow cuyo origen ahora no recuerdo :(
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vector<string> customSplit(string& linea, char delimitador) | |
{ | |
linea.erase(remove_if(linea.begin(), linea.end(), ::isspace), linea.end()); | |
string palabra; | |
vector<string> palabras; | |
istringstream palabraStream(linea); | |
while (getline(palabraStream, palabra, delimitador)) { | |
palabras.push_back(palabra); | |
} | |
return palabras; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment