Sort out the input and output of c ++

Source: Internet
Author: User

I have always understood this input and output, but I am not particularly clear. Chaos is the root cause of all worries! It's too late. I haven't checked it carefully. If you have any errors, please forgive me... 1.> skip the space tab and line feed, that is, 12 13 14 15 cin> a; will directly read 12, then skip the space, directly to 13 2. cin. get (char &) does not skip spaces, and returns the reference of isteream that calls the get (Note: when it reaches the end of the file, it returns false, so it can be used to determine whether it has reached the end of the file) 3. cin. get (void) and cin. similar to get (char &), do not skip spaces, but pass the input to the program in the form of return values (note that its return type is integer, but EOF is returned at the end of the file) what is EOF? (1) computer terms, usually EOF (End Of File). In the operating system, it indicates that no more data can be read from the data source. (2) In the while LOOP, EOF is used as the end mark of the file. The file with EOF as the end mark must be a text file. In text files, data is stored in the form of ASCII code values of characters. We know that the ASCII code value ranges from 0 ~ 255, it is impossible to see-1, so EOF can be used as the end mark of the file (3) in C language, when the data is stored in binary form to the file, there will be a value of-1, in this case, EOF cannot be used as the end mark of the binary file. 4. istream & cin. get (char *, int, char) istream & cin. get (char *, int) istream & cin. getline (char *, int, char) istream & cin. getline (char *, int) reads a row until the maximum number (for example, cin. get (c, 10), the maximum number is 9, when reading 9th, stop reading) or encounter line breaks (default: '\ n') their main differences are: get () will leave the linefeed (default) in the input stream. The next read will be the linefeed getline () will extract the linefeed (default) and discard the linefeed in the input stream (therefore, we often use cin this way. get (pl, size ). get (); The get next to it is used to read line breaks.

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: 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.