David Harmon wrote:
std::copy(istream_iterator<char>(cin),
istream_iterator<char>(),
ostream_iterator<bitset<8> >(cout, "\n"));
Note that this will remove whitespaces or, more precisely, the bits
representing them: 'std::istream_iterator<T>' uses the formatted input
operations to read the data. By default, the formatted input functions
skip leading whitespace, even if they just read a single character.
Also, there is no guarantee that 'char' has exactly 8 bits: the
standard only guarantees that it has at least 8 bits. You might want to
use this instead:
/**/ std::copy(std::istreambuf_iterator<char>(std::cin) ),
/**/ std::istreambuf_iterator<char>(),
/**/ std::ostream_iterator<
/**/ std::bitset<std::numeric_limits<char>::digits>
/**/ >(std::cout, "\n"));
--
<mailto:di***********@yahoo.com> <http://www.dietmar-kuehl.de/>
<http://www.contendix.com> - Software Development & Consulting