cout<< in C + + does not flush buffer and output without encountering Endl.

Source: Internet
Author: User

Today on Mac Xcode directly write cout<< do not encounter enl and do not flush buffer data can not output.

Remember that before the VS and g++ directly output, and then read the C + + input and output buffer refresh problem, resolved this contradiction.

Case of Buffer emptying:

1. The program ends normally. As part of the return work of main, all output buffers are emptied.

2. At some indeterminate time, the buffer may be full, in which case the buffer will be refreshed before the next value is written.

3. Flush the buffer with the operator display, as with Endl.

4. After each output operation is complete, set the internal state of the stream with the UNITBUF operator, thereby emptying the buffer.

5. The output stream can be associated with an input stream, and its associated output buffers are flushed when the input stream is read.

That is, the above 3rd vs and g++ empty the buffer when the buffer is full and then output the program.

cout<< in C + + does not flush buffer and output without encountering Endl.

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.