The difference between C + + cout Cerr and Clog

Source: Internet
Author: User

we all know that C + + has pre-defined CIN (standard input stream) and cout (standard output stream). But today it popped out again. Two cerr (standard error stream (non-buffered)) and clog (standard error stream (buffered))
, the spirit of learning to improve the online search for relevant content, the following is from Baidu know what to get
PS: I don't know if it will infringe ...

First, an example is used to analyze the difference between cout and Cerr, compile the following code after the link is generated test.exe
1#include <iostream.h>2     3 intMain ()4 {5cout <<"Hello World---cout"<<Endl;6Cerr <<"Hello World---cerr"<<Endl;7      return   0;8}

 


that is, the output of cout can be redirected to a file, and Cerr must be output on the monitor .

re-analyze the difference between cerr and clog, both are standard error streams, the difference is that Cerr does not go through the buffer, directly to the display output information, The information in the clog is stored in the buffer when the buffer is full or when Endl is encountered.

, You say, where do you go to borrow memory and store your error messages?
so there's cerr. The goal is to get support for the output function in the emergency situations where you need it most.
several sentences "at the same time" appear on the screen (from the memory to the video, then refresh the screen).

pps: The above content is from the network and is not validated and is for learning reference only.

C + + cout Cerr and Clog differences

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.