C + + Primer Note (1) fighter input and output data processing in the foundation

Source: Internet
Author: User

I'm going to take a good look again today. C + + Primer This very classic book, The Notes begin:

1. Each C + + program contains one or more functions, which must have a main, the operating system by calling main to start running the program;

2. Functions include: return type, function name, line parameter list, function body. The return type of the main function must be an int integer type. In a general system, the return value of main is used to indicate the state, and a return value of 0 indicates success, not 0 defined by the system;

3. Input/Output (IO): The iostream library in the standard library (STD) contains two base types IStream and Ostream, respectively, the input stream and the output stream, and a stream is a sequence of characters that is read from or written to the IO device,

STD defines 4 IO objects, IStream cin, called standard input, ostream cout, called standard output, ostream ceer and clog, usually ceer to output warnings and error messages, clog to output general information;

4.cout and CIN are output left operand, so a sentence cout<<v1<<v2 is equivalent to two sentences cout<<v1;cout<<v2; and the same CIN can be;

5.<< output operator,>> input operator,:: scope operator,//sentence specifier,/* Multi-statement Program statements */Comment a paragraph, in addition: =,==,!=,<=,>=,<,>,++,--;

Below is a small program to cover the above small knowledge points:

//read the variable number of input data for processing;//the while will loop until a file terminator is encountered, and Windows Terminator is ctrl+z,linux to Ctrl+d;#include<iostream>//header Fileusing namespaceStd//with Std::cout a function;intMain () {intsum =0; intval =0;  while(cin>>val) {Sum= Sum+val;//same sum + = val;} cout<<"sum ="<<sum<<Endl; System ("Pause");//causes the System window to pause the command, if does not add to see cout result, with OpenCV in Waitkey;    return 0;}

C + + Primer Note (1) fighter input and output data processing in the foundation

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.