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?

What is class definition, Class Definition The following is the general...

Class Definition The following is the general format of defining a class template: class tag_name                  {                    public  :               // Must

Creates and implements a class to represent the queue, Purpose This ass...

Purpose This assignment is an exercise in implementing the queue ADT using a singly-linked list. This assignment also introduces the concept of templates. Assignment Th

Data Handling in computers, though the ascii is called 7-bit code. why do w...

though the ascii is called 7-bit code. why do we use 8-bits to represent a character?

If one won''t explicitly call the destructor of a local then , if one won't...

if one won't explicitly call the destructor of a local; then how does he handle the above situation?

ASCII, A string S is said to be "Super ASCII", if it contains the character...

A string S is said to be "Super ASCII", if it contains the character frequency equal to their ascii values. String will contain only lower case alphabets (''a''-''z'') and the asci

Flow chart, obtain two numbers from thekey board,and determain and display(...

obtain two numbers from thekey board,and determain and display(if either)is the larger of two numbers.

Graphical user interface designed for the output peripherals, Introduction ...

Introduction to I/O interfacing, discuss microcontrollers applications in industry. Detailed product design specifications that have sections on both hardware and software inclu

C++ Program Please see where i do mistake, #include #include #include ...

#include #include #include #include #include class Employee { private: char *Name; //Set them as pointers... int IdNumber; char *Department; char *Position; public: voi

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