Why does my program not output:
10
1.546
,Apple 1
instead of
10
1
here\'s my program
You should do the below changes:
string str = "10 1.546 Apple 1";
And
stream >> a >> b >> dummy >> c;
In your example, dummy would have got the string ",1.546,Apple" . Because till a non-numeric char is encountered, it is fed to variable a. After that everything is added to dummy ( a string ) until the default delimiter (space) is reached