I'm trying to read from standard input and distinguish each character from one another by its decimal value. From what I understand, a Line Feed (10) and a Carriage Return (13) will be interpreted as the same character. I want to distinguish between the two. I know if I was reading from a file I could open it using the ios::binary parameter. But what about if I am reading from standard input?
ios::binary means you want to open a file in the binary mode for input/output (when the file contains binary data) Refer to this for detailed expl. They are file modes in C++. ios::out means you want to open a file in the output mode (for writing data to a file)
To read a binary file in C++ use read method. It extracts a given number of bytes from the given stream and place them into the memory, pointed to by the first parameter. If any error is occurred during reading in the file, the stream is placed in an error state, all future read operation will be failed then.
You can read from std::cin by using get. This method is specially designed for reading unformatted data (see doc)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With