-1

I am working on a project that works with bits.

Currently we can read in a file name, open it in binary and get a char array from the binary file. If not file name is given, I have to get the char array from stdin. The input will thus be of variable length.

Is there a way to read the entire stdin into a char array?

Thank you

Ringo16
  • 9
  • 2
  • 1
    Read it into a collection (string, vector, etc.) instead. http://stackoverflow.com/q/2602013/179910 – Jerry Coffin Jun 03 '14 at 22:39
  • 2
    `std::vector data(std::istream_iterator{std::cin}, std::istream_iterator{});`? – Mooing Duck Jun 03 '14 at 22:40
  • This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself. – πάντα ῥεῖ Jun 03 '14 at 22:42

1 Answers1

0

Use std::basic_istream::get to get values and put it into an array

Orelsanpls
  • 18,380
  • 4
  • 31
  • 54