In Linux programming, printf shows no line-wrapping buffering problem

Source: Internet
Author: User

Recently in the programming of Linux network, always encountered such a thing, the program logic is not wrong, but the program run to a place to stop there, and later found in PRINRF () to add a line to run normally, such as "printf (" 123 "); "Change to" printf ("123\n"); "Just fine.

Slowly found a blog post can explain the problem: Blog Link: http://blog.csdn.net/ferlansue/article/details/7925522

The explanations are as follows:

printf will send things to the buffer, and if the buffer does not flush to the words, you will not see things on the screen, but can cause the buffer to flush to the situation has these:

1 force flush Standard output Cache fflush (stdout);
2, put the buffer into the content containing/n/r;
3, the buffer is full;
4, need to take things from the buffer time, such as the implementation of scanf;

In Linux programming, printf shows no line-wrapping buffering problem

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.