Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8646929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:56:17+00:00 2026-06-12T12:56:17+00:00

In my experiments with the following code snippet, I did not find any particular

  • 0

In my experiments with the following code snippet, I did not find any particular difference whether i created the streams with/without the ios:binary mode:

int main()
{
    ifstream ostr("Main.cpp", ios::in | ios::binary | ios::ate);
    if (ostr.is_open())
    {
        int size = ostr.tellg();
        char * memBlock = new char[size + 1];
        ostr.seekg(0, ios::beg);
        ostr.read(memBlock, size);
        memBlock[size] = '\0';
        ofstream file("trip.cpp", ios::out | ios::binary);
        file.write(memBlock, size);
        ostr.close();
    }
}

Here I am trying to copy the original source file into another file with a different name.

My question is what is the difference between the read/write calls(which are associated with binary file IO) when an fstream object is opened with/without ios::binary mode ?
Is there any advantage of using the binary mode ? when to and when not to use it when doing file IO ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T12:56:18+00:00Added an answer on June 12, 2026 at 12:56 pm

    The only difference between binary and text mode is how the ‘\n’ character is treated.

    In binary mode there is no translation.

    In text mode \n is translated on write into a the end of line sequence.
    In text mode end of line sequence is translated on read into \n.

    The end of line sequence is platform dependant.

    Examples:

    ASCII based systems:

    LF    ('\0x0A'):      Multics, Mac OS X, BeOS, Amiga, RISC OS
    CRLF  ('\0x0D\0x0A'): Microsoft Windows, DEC TOPS-10, RT-11
    CR:   ('\0x0D'):      TRS-80, Mac OS Pre X
    RS:   ('\0x1E'):      QNX pre-POSIX implementation.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my experiments I haven't been able to find any functional difference between git
As an experiment I ran the following code snippet (simplified): public class SGamePlay extends
After some experiments I ended up with the following code to perform Search and
I frequently code numerous experiments to test various algorithms, libraries, or hardware. All code,
Is there any difference between @(posedge Clk); a<= 1'b1; and @(posedge Clk) a<= 1'b1;
I wrote the following code today to experiment with returning pointers to allocated memory.
The following code utilize DOM Mutation Event DOMNodeInserted to detect the existence of the
Given the following code: $(div.now span).text('now'); $(div.30days span).text('30days'); $(div.60days span).text('60days'); If I want to
Consider the following snippets of code: Exhibit A: $_REQUEST = json_decode(stripslashes(json_encode($_REQUEST, JSON_HEX_APOS)), true); Exhibit
Sometimes when I'm writing experimental code in Mathematica, I'm wary as to whether I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.