I have the following code:
#include <sstream>
#include <iterator>
#include <iostream>
int main()
{
std::stringstream str; str << "abc\ndef";
std::cout << "[" << str.str() << "]" << std::endl;
std::istream_iterator<char> it(str), end;
for (; it != end; ++it)
{
std::cout << "[" << unsigned(*it) << "]";
}
std::cout << std::endl;
return 0;
}
And the output is:
[abc
def]
[97][98][99][100][101][102]
Why std::istream_iterator ignored the new-line character?