Reputation: 1276
After binding cin to istream_iterator and reading its I don't have whitespaces:
iter = istream_iterator<char>(std::cin);
istream_iterator<char> iend;
for(int i=0;i<maxBufferSize;++i)
{
if(iter==iend)
return STREAMBUFFER_EOF;
c = *iter;
buffer += c;
iter++;
}
if(iter==iend)
return STREAMBUFFER_EOF;
return STREAMBUFFER_OK;
Is there way to configure it to not ignore whitespaces?
Upvotes: 2
Views: 288
Reputation: 103713
If your goal is to read unformatted character data from the stream, you could use std::istreambuf_iterator
instead, without needing to change any format flags of the stream.
std::istreambuf_iterator<char> iter(std::cin), iend;
for(int i=0;i<maxBufferSize;++i)
...
Upvotes: 3
Reputation: 1276
Sorry answer is very simple, before binding cin to iterator you have to use manipulator noskipws:
std::cin>>noskipws;
iter = istream_iterator<char>(std::cin);
Now it's working.
Upvotes: 2