-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

3
  • 1
    Read it into a collection (string, vector, etc.) instead. stackoverflow.com/q/2602013/179910 Commented Jun 3, 2014 at 22:39
  • 2
    std::vector<char> data(std::istream_iterator<char>{std::cin}, std::istream_iterator<char>{});? Commented Jun 3, 2014 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. Commented Jun 3, 2014 at 22:42

1 Answer 1

0

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.