Hello I recently asked a question about separating n DOUBLE numbers and they deleted it because they say that it is a duplicate so in their answer they put a link to the "Answer" because that "Answer" is not working for me
How can I solve this error?
#include<iostream>
#include<sstream>
using namespace std;
void separate(string product)
{
std::istringstream is(product);
double n;
int i = 0;
while(is >> n)
{
cout << i << ": " << n << " ";
i++;
}
}
int main()
{
string product1, product2;
cin >> product1;
separate(product1);
}
Input:
12 1 5.30
Output:
0: 12
I need the output to be:
0: 12 1: 1 2: 5.30