The 1th chapter begins

Source: Internet
Author: User

1.1

Main function definition

int Main () {    return0;   }

Where return 0 indicates success in most systems, non-zero indicates that the program has an error.

1.2

iostream

The iostream contains two base types, IStream and Ostream, which represent the input and output of the stream, respectively.

There are four IO objects defined, namely:

Objects of type Cin:istream

Objects of type Cout:ostream

Cerr:ostream types of objects, output warnings and error messages

Clog:ostream object of type, output generic message

Endl

Endl is a manipulator that writes Endl to end the current line and brushes the contents of the buffer associated with the device to the device, which guarantees that the in-memory data is actually written to the output stream.

1.4.3 Reading non-quantitative data

#include <iostream>intMain () {intsum =0, value =0; //read until end-of-file, calculating a running total of all values read     while(Std::cin >>value) Sum+ = value;//equivalent to sum = sum + valueStd::cout <<"Sum is:"<< sum <<Std::endl; return 0;} 

When the input is invalid, or if the file solution is encountered, Std::cin returns false

In Windows, the file terminator is CTRL + Z

UNIX systems, including Mac OS X, file Terminator Ctrl+d

1.5.1 Using file redirection

$ myApp <infile >outfile

This can be entered into MyApp from the file infile, outputting the program output to outfile.

The 1th chapter begins

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.