18: String-char type String

Source: Internet
Author: User
Tags closing tag
1 What is a string? The string isAn array of characters ending with a null character (\ 0).
The ASSII code for the null character is: 0, the ASCII code for the space is 32
The role of 2

That is, a null character is the closing tag, such as Cin,cout. They all end with a null character, and they will stop typing or outputting after encountering a null character.


Cin.ignore (a,ch) extracts characters from the input stream (CIN), and the extracted characters are ignored (ignore) and are not used. Each discarded one character,
It counts and compares characters: if the count reaches a or the discarded character is CH, the Cin.ignore () function terminates; otherwise, it continues to wait
The default parameter is Cin.ignore (1,eof), which is to Fu Qing the 1 characters before EOF and clear one character without encountering EOF
One of its most common functions is to clear the contents of input buffers that end with a carriage return, eliminating the effect of the last input on the next input.
The end tag of 4 cin.get (char[], n) is a newline character. Therefore, a whitespace character (a space, tab) is encountered and does not end. At the same time, after the input is finished, that is, when the user enters the first carriage return, Cin.get automatically
So it actually saves the valid character is its second parameter minus 1.

18: String-char type String

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.