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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T23:40:56+00:00 2026-05-11T23:40:56+00:00

We build complicated console-based tools that produce a lot of commentary on the console.

  • 0

We build complicated console-based tools that produce a lot of commentary on the console. These tools process a lot of data and so runs are expensive and we don’t like to do them more often than necessary, especially during testing where we already have to run them repeatedly. During such tests, we often log the result to a file to capture this commentary for inspection:
C:> [ourcommand] >log.txt
When the application runs to completion, this works great.

If the application crashes (illegal memory reference, etc.), Windows nastily chops off the log file before the tail end of the commentary so we can’t see what was occuring at the point of the crash. It also chops of the console output at the same place. So, when we get an truncated log file, we have to do it all again without the log file, to see the final answer. Windows doesn’t seem to buffer the console output if not logging.

Is there a way to tell Windows not to buffer the console output while logging? Our application does use the (Windows) C runtime system and awhile back we used “setvbuf”
as follows:
setvbuf(stdout, NULL, _IONBF, 0);
but to no avail.

  • 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-05-11T23:40:57+00:00Added an answer on May 11, 2026 at 11:40 pm

    You can flush the console’s buffer at any point:

    Console.Out.Flush();
    

    This uses TextWriter.Flush().

    If you need to make sure this always happens, it’d be fairly easy to write a method for console that worked like WriteLine but included a flush statement at the end.


    Edit:

    You didn’t specify a language… I’m going to write an example using C#.

    In C#, you could easily make a static utility class that provided a method like:

    public static class FlushingConsole {
        public static void WriteLine(string format, params Object[] args) {
            Console.WriteLine(format, args);
            Console.Out.Flush();
        }
        // Add other overloads as required
    }
    

    Then just call:

    FlushingConsole.WriteLine(....);
    

    The same approach should work in pretty much any other language, as well.


    Edit 2:

    Since you’re using C++, there are a couple of options other than setvbuf that may be of interest.

    First, you should be able to turn off the buffering in cout by doing:

    cout.unsetf(ios_base::unitbuf);
    

    You also may need to set sync_with_stdio if you’re mixing stdio (ie: printf) with iostreams.

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

Sidebar

Related Questions

I have a build process that creates an ear in a fairly complicated manner
I am trying to build a complicated web project that involves 4 websites that
I want to build a service that will pass the data read from the
I am trying to build a complicated spreadsheet and I need a statement to
I'm going to build a rather complicated application in html5 with some heavy javascripting.
I have a very complicated site built on CSS3 that has html elements 3d-transformed,
After build, I need to modify an HTML file that points the client to
I want to build a stack of resources that will be used by different
Im finding it very hard to learn how to build more complicated queries in
I build a CFG out of an arbitrary IL and want to convert that

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.