Is is possible to stringstream this way? to convert from string to int?
- by John
Is it possible to stringstream like this?
I am trying to read with ifstream and convert it.
string things = "10 11 12 -10";
int i1;
int i2;
int i3;
int i4;
stringstream into;
into << things;
into >> i1;
into >> i2;
into >> i3;
into >> i4;
I expect it to be :
i1 = 10
i2 = 11
i3 = 12
i4 = -10
is that correct?
Can the same stringstream variable be used multiple times?
When I tried, the first time was ok but everything else later on is just 0.