My question is this, I have an integer text file which I need to get every complete number that is separated by commas. I know that with spaces the compiler knows that they are different things, but how can I do it if they are commas?
My question is this, I have an integer text file which I need to get every complete number that is separated by commas. I know that with spaces the compiler knows that they are different things, but how can I do it if they are commas?
You can use std::getline
and std::stringstream
:
std::string linea;
while(std::getline(fichero,linea))
{
std::stringstream stream(linea);
std::string valor;
std::cout << "Contenido de la linea:\n";
while(std::getline(stream,valor,','))
{
std::cout << "valor leido: " << valor << '\n';
}
std::cout << "Fin de la linea\n";
}
For future questions please, put code that shows where you are stalling.