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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:16:18+00:00 2026-05-29T12:16:18+00:00

Sometimes we put some debug prints in our code this way printf(successfully reached at

  • 0

Sometimes we put some debug prints in our code this way

printf("successfully reached at debug-point 1\n"); 

some code is here

printf("successfully reached at debug-point 2"); 

After the last printf a segmentation fault occurs.

Now in this condition only debug-point1 will be print on stdio debug-point 2 print was written to stdio buffer but its not flushed because it didn’t get \n so we thinks that crash occur after debug-point1.

To over come from this, if I disable buffering option with stdio and stderr stream like this way

setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0);

Then, is this safe to do this?

Why are all streams by default line buffered ?

Edit :

Usually what is the size of such by default allocated buffer for any file stream? I think it’s OS dependent. I would like to know about Linux.

  • 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-29T12:16:18+00:00Added an answer on May 29, 2026 at 12:16 pm

    why all stream are by default line buffered

    They are buffered for performance reasons. The library tries hard to avoid making the system call because it takes long. And not all of them are buffered by default. For instance stderr is usually unbuffered and stdout is line-buffered only when it refers to a tty.

    then is this safe to do this?

    It is safe to disable buffering but I must say it’s not the best debugging technique.

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

Sidebar

Related Questions

In one place of code I do something like this: FormModel(.. some data here..).put()
Sometimes I need to quickly extract some arbitrary data from XML files to put
We have been using asp.net mvc for development. Sometimes, we need to put some
When I am in debug and I am dealing with some legacy code or
I have a ListView which sometimes I need to put around 10000 items in.
Sometimes I have to work on code that moves the computer clock forward. In
Sometimes a labeled break or continue can make code a lot more readable. OUTERLOOP:
Here I need to cache some entites, for example, a Page Tree in a
Is it possible to put some data into gnuplot right on it's prompt? Like
i am looking to put together some logic to look at a particular number

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.