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