C ++ primer 1.2 first-glance input/output stream

Source: Internet
Author: User

C ++ does not directly define any input or output statements, which are provided by the standard library.

The standard library defines four IO objects.

They are:

Cin standard input stream

Cout standard output stream

Cerr standard error stream

Clog standard error stream

Generally, the system executes these objectsProgramIn this way, when we read data from Cin, the data is read from the window of the execution program.

When reading cerr, clog, and cout, the data is first transmitted in the same window.

When most operating systems are running, they define methods to redirect input and output streams. The redefinition method can be used to associate these watershed objects.

 

In C ++, each expression has a result, which usually acts the output operator on the value produced by its operand. When the operator is an output operator, the result is the value of the Left operator, that is to say, the value returned by the output operation is output Liu.

Endl is a special operator. In addition to line breaks, it can also refresh the buffer associated with the device. By refreshing the buffer, you can immediately see the output written to the stream. In special use of Endl, the output statements inserted by programmers during the book picking process should be to refresh the output stream ,. That is, Endl

 

About namespaces: Using namespaces allows programmers to avoid conflicts caused by accidental use of the names defined in the library with the same name, because the names in the standard library are defined in the namespace, therefore, programmers can use the same name in their own namespaces.

 

For the definition of variable initialization, the initial value should be assigned to the variable when defining the variable, unless it is determined that the variable will overwrite the initial value before other intentions are used. If the variable cannot be reset before reading the variable, initialize the variable

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.