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

Assignment Help:

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.

 


Related Discussions:- In binary mode how can i open a stream?

Define the data file in c programming, Define the Data File in C Programmin...

Define the Data File in C Programming? Many applications needs that information can written to or read from an auxiliary memory device. Such information is stock up on the memo

Boardcoloring, color representation 0,1,2,3,4,5,6,7,.......

color representation 0,1,2,3,4,5,6,7,.......

C++ code, write c++ programm calculate electricity bill with person name,us...

write c++ programm calculate electricity bill with person name,use ,id

What is the difference among const char *mypointer &char *, What is the dif...

What is the difference among const char *myPointer and char *const myPointer?  A: Const char *myPointer is a non constant pointer to constant data; whereas char *const myPointer

Program for design and simulate a basic risc processor, Overall Program Obj...

Overall Program Objective: You will design and simulate a basic RISC processor.   You will create and encode an instruction set.  Your final task will be to "compile" a program

What does extern "c" int func(int *, A: This will turn o_ "name mangling" f...

A: This will turn o_ "name mangling" for func so that one can connect to code compiled by a C compiler.

Luminous Jewels - The Polishing Game, Byteland county is very famous for lu...

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

Recursion, Given a string, print all possible palindromic partitions using ...

Given a string, print all possible palindromic partitions using recursion

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd