[C++primer] [01] Quick Start

Source: Internet
Author: User

1.1 Writing a simple C + + program

The main function is the only function that is explicitly called by the operating system

Compile execution


1.2 First Glimpse input/output

iostream: input/output stream

Istream:cin Read from window

Ostream:cout, Cerr, clog output to window

Write to stream

Std::cout << output Items << Std::endl; Write right operand to ostream

The output operator (<<) returns the value of the left operand, the operator (Endl) writes the output stream, wraps the line, and refreshes the buffer associated with the device. By flushing the buffer, you can immediately see the output written to the output stream.

Use a name from the standard library

Using namespaces (namespace), you can avoid inadvertently using names that are the same as the names in the library to cause conflicts

Scope operator (::) scope operator

Std::cin, Std::cout, Std::endl

Read the Inflow

Std::cin >> inputs >> Std::endl; Read data from IStream to right-hand operand

Input operator (>>) returns the value of the left operand

If you cannot guarantee to reset a variable before reading it, you must initialize the variable

1.3 About annotations

Comment to/* */double slash//

Not nested,/*/*/* * ERROR

1.4 Control Structure


Read in Unknown purpose input while (std::cin >> value), encountered file terminator or invalid input, IStream object invalid, condition failed

Input file Terminator: Ctrl + D (Linux)

[C++primer] [01] Quick Start

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.