In binary mode how can i open a stream?, C/C++ Programming

A: Use std::ios::binary.

Some operating systems differentiate among text and binary modes. In text mode, end-of-line sequences and perhaps other things are translated; in binary mode, they are not. For instance, in text mode under Windows, "\r\n" is translated in "\n" on input, & the reverse on output.

To read a file in binary mode, employ something like this:




void readBinaryFile(const std::string& filename)


std::ifstream input(filename.c_str(), std::ios::in | std::ios::binary);

char c;

while (input.get(c)) { something with c here...



Note : input >> c discards leading whitespace, thus you won't normally employ that when reading binary files.


Posted Date: 3/21/2013 7:44:14 AM | Location : United States

Related Discussions:- In binary mode how can i open a stream?, Assignment Help, Ask Question on In binary mode how can i open a stream?, Get Answer, Expert's Help, In binary mode how can i open a stream? Discussions

Write discussion on In binary mode how can i open a stream?
Your posts are moderated
Related Questions
Differentiate between a template class and class template in C++? Ans) Template class: A generic definition or a parameterized class not instantiated until the client gives the

The ability to verify at run time the type of an object by using the typed operator or the dynamic_cast operator.

how much is it to fix a small data struct in a sorted list that pass itemtypes. all the code is written just logical errors

A: No. If they're utilized properly, they increase encapsulation. You frequently require splitting a class in half while the two halves will have distinct numbers of instances o

I want Packet capture analysis Project Description: Need assistance in debugging some packet capture Skills required is C Programming

Implement, in rPeANUt, the a Fibonacci function by using the simple recursive approach. The Fibonacci function can be implemented in c as follow: int fib(int x) {   if (x

Pointer Types Pointer holds the address of an object, permitting for the indirect manipulation of that object. They are used in creating linked data structures like lists, tree

Prepare a MT4 EA to clone MT4 Trades to a Binary Options Platform Project Description: I want an EA that clones MT4 Trades to Globaltrader365, GT Options and if possible othe

Design and implement a library system that does the following: ? Takes details of a student/library users: first name, last name, other names, user ID number, and nationality. Th