I would like to know how I can separate many numbers from a single string in the following way, or in another way but in a very short way:
void separate(string product)
{
std::string orbits ("365.24 29.53 234.455");
std::string::size_type sz; // alias of size_t
double earth = std::stod (orbits,&sz);
double moon = std::stod (orbits.substr(sz));
std::cout << "The moon completes " << (earth/moon) << " orbits per Earth year.\n";
}
output:
12,3684