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 8470573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:33:26+00:00 2026-06-10T16:33:26+00:00

What the point of the std::ios_base::ate (other than std::ios_base::app , for example) and std::ios_base::trunc

  • 0

What the point of the std::ios_base::ate (other than std::ios_base::app, for example) and std::ios_base::trunc (other than std::ios_base::out, for example)?

And should i preferly write std::ios_base::smth instead of std::ios::smth?

  • 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-10T16:33:27+00:00Added an answer on June 10, 2026 at 4:33 pm

    std::ios_base::ate position the cursor at the end of the text whereas std::ios_base_app appends text (with a write operation) at the end, though you can still read from the beginning 🙂

    std::ios_base::trunc truncates the file so it is emptied, whereas std::ios_base::out just specify you want to write to the stream.

    I currently can’t quote the standard (on my tablet and Acrobat Reader won’t let met copy) but from paragraph 27.4.2.1.4 from ISO 14882:1998 the information you can see on the link is almost exact: http://cplusplus.com/reference/iostream/ios_base/openmode/

    To sum up:

    std::ios_base::app = append
    

    Append at the end of the stream by “seek[ing] to end before each write”

    std::ios_base::ate = At The End
    

    Open and seek immediately at the end after opening

    std::ios_base::binary = binary
    

    Perform operation in binary as opposed to text

    std::ios_base::in = input
    

    Open in read mode

    std::ios_base::out = output
    

    Open in write mode

    std::ios_base::trunc = truncate
    

    Truncate the stream on opening.

    These values are just flags, so you can open a stream in read/write binary at the end with :

    std::ios_base::in | std::ios_base::out | std::ios_base::ate | std::ios_base::binary
    

    Concerning the way of using those values, it is as you wish. They are declared as public static fields in std::ios_base class (see 27.4.2) thus it is possible to access them using std::ios::ate or even something like cout.binary !


    The points where you must take attention is that std::ios_base::ate does NOT imply std::ios_base::app nor does std::ios_base::out implies std::ios_base::trunc. Each field has a different meaning, and a different case of use, though most of them can’t be used alone 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm convinced at this point that I should be creating subclasses of std::exception for
I have a std::vector that holds a Point struct (x,y,z and some other non-pointer
That is the point. How to write and read binary files with std::vector inside
I have two (unrelated) classes. The first one is Point: typedef std::complex<double> complex_number; class
Right now I am using std::pair to represent a 2d point in c++. However,
Consider this example: #include <iostream> class myclass { public: void print() { std::cout <<
It looks like std::cout can't print member function's address, for example: #include <iostream> using
Kindly point out if i have missed something? I have a project with type
I'd like to write my own lexical_cast which preserves the decimal point when converting
Originally I had a member that was a std::vector<Point> with a method that did

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.