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:

#include

#include

#include

void readBinaryFile(const std::string& filename)

{

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

char c;

while (input.get(c)) {

...do 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
Project Description: We are aiming to prepare an industry first in the m-commerce world. M-commerce payment processing programmers required Skills required are C Programmi

A Padovan string P(n) for a natural number n is defined as: P(0) = ‘X’ P(1) = ‘Y’ P(2) = ‘Z’ P(n) = P(n-2) + P(n-3), n>2 where + denotes string concatenation. For a string of t

how to decode the numerals to string..

A: No. Syntax wise it is permitted. But then the function is no longer Inline. Since the compiler will never know how deep the recursion is at compilation time.

Overloading Unary Operators class sign {int a,b,c; public: sign(){}; sign(int,int,int); void putdata(void); void operator-(); }; void sign::operator-() {a=

1.jewels can only be removed for polishing from either end of the necklace. 2.cost of polishing=sitting number*colour value of jewels.

A: The answer to this lies actually, how they used. Along ++i(PreIncrement) the variable is incremented and new value is returned. Thus it needs one instruction to increment the va

What is memory allocation? Memory Allocation : It is the method of allocating memory storage to program in such that the program can be run.

With this assignment you will build a toy program that manipulates pointers to integers. You will develop the same main program fragment in both C and Assembler. Thus, you'll get t

C Program for 5 FUNCTION OF VOWELS, CNT_WORDS, REVERSE void input(char a[]); void output(char a[]); void reverse(char a[], char b[]); char poli(char a[], char b[]);