Hello! I've just started using stringstream's but I've encountered a problem. Why does this code print 0 ?
#include<iostream>
#include<sstream>
using namespace std;
int main()
{
stringstream ss;
int i;
ss<<0;
ss>>i;
ss<<1;
cout<<ss.str()<<endl;
return 0;
}
Thanks in advance.
This should work
Why does adding ' ' work?
It prints "0 1"
And what do you want to get?
I don't know much about stringstream,but I expected to get '1' .
this code produces output as
1
.