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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:23:59+00:00 2026-06-05T02:23:59+00:00

I’m reading accelerated c++ and the author writes: Flushing the output buffers at opportune

  • 0

I’m reading accelerated c++ and the author writes:

Flushing the output buffers at opportune moments is an important habit when you are writing programs that might take a long time to run. Otherwise, some of the program’s output might languish in the systems buffers for a long time between when your program writes it and when you see it

Please correct me if i misunderstand any of these concepts:

  • Buffer: a block of random access memory that is used to hold input or output temporarily.
  • Flushing: freeing up random access memory that had been… eh.. assigned to certain ..umm

There is this explanation I found:

Flushing an output device means that all preceding output operations are required to be completed immediately. This is related to the issue of buffering, which is an optimization technique used by the operating system. Roughly speaking, the operating system reserves (and usually exerts) the right to put the data “on stand by” until it decides that it has an amount of data large enough to justify the cost associated to sending the data to the screen. In some cases, however, we need the guarantee that the output operations performed in our program are completed at a given point in the execution of our program, so we flush the output device.

Continuing from that explanation i read that the three events that cause the system to flush the buffer:

  1. Buffer becomes full and will automatically flush
  2. The library might be asked to read from standard input stream *is standard input stream like std::cin >> name ;
  3. The third occasion is when we explicitly tell it to. How do we explicitly tell it to?

Despite I don’t feel like a fully grasp the following:

  • What a output buffer is vs just a buffer and presumable other types of buffers…
  • What it means to flush a buffer. Does it simply mean to clear the ram?
  • What is the “output device” refereed to in the above explanation
  • And finally after all this when are opportune moments to to flush your buffer…ugh that doesn’t sound pleasant.
  • 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-05T02:24:02+00:00Added an answer on June 5, 2026 at 2:24 am

    You explicitly flush a stream with your_stream.flush();.

    What a output buffer is vs just a buffer and presumable other types of buffers…

    A buffer is usually a block of memory used to hold data waiting for processing. One typical use is data that’s just been read from a stream, or data waiting to be written to disk. Either way, it’s generally more efficient to read/write large blocks of data at a time, so read/write an entire buffer at a time, but the client code can read/write in whatever amount is convenient (e.g., one character or one line at a time).

    What it means to flush a buffer. Does it simply mean to clear the ram?

    That depends. For an input buffer, yes, it typically means just clearing the contents of the buffer, discarding any data that’s been read into the buffer (though it doesn’t usually clear the RAM — it just sets its internal book-keeping to say the buffer is empty).

    For an output buffer, flushing the buffer normally means forcing whatever data is in the buffer to be written to the associated stream immediately.

    What is the “output device” refereed to in the above explanation

    When you’re writing data, it’s whatever device you’re ultimately writing to. That could be a file on the disk, the screen, etc.

    And finally after all this when are opportune moments to to flush your buffer…ugh that doesn’t sound pleasant.

    One obvious opportune moment is right when you finish writing data for a while, and you’re going to go back to processing (or whatever) that doesn’t produce any output (at least to the same destination) for a while. You don’t want to flush the buffer if you’re likely to produce more data going the same place right afterward — but you also don’t want to leave the data in the buffer when there’s going to be a noticeable delay before you fill the buffer (or whatever) so the data will get written to its destination.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post

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.