C + + Primer Note string

Source: Internet
Author: User
Tags uppercase letter

When designing a header file, it is important to remember the difference between the definition and the declaration. The definition can only occur once,
The declaration can appear multiple times (2nd. 3.5). Definition, so should not be put
In the header file:


C + + Primer Chapter III notes standard library type string

1. The fully qualified standard library name must be used in the header file

The header file is copied into our program code, causing the program using the header file to use the

using namespace Std; or using std::string; such as

2. String S;cin >> s;

At this point, all whitespace characters in the front are skipped, and the characters are read again until the white space character stops

3. EOF, the while termination condition in this code

 int   main () { string   word;  //  read until end-of-file, writing each         Word to a new line  while  (cin >> word)    cout  << word << Endl;  return  0     

4.getline reads content until a newline is encountered, directly encounters a newline, string is empty getline (CIN, line)

Operation of 5.string objects

S.empty (), S is a string, returns True, or returns False, S.size (), s[n], s1+s2,s1 = s2, V1 = v2,! =, <, <=, >,>=

6.string::size_type type

Functions in 7.cctype

Isalnum (c) True if C is a letter or a number.
Isalpha (c) True if C is a letter.
Iscntrl (c) True if C is the control character
IsDigit (c) True if C is a number.
Isgraph (c) True if C is not a space but printable.
Islower (c) True if C is a lowercase letter.
Isprint (c) True if C is a printable character.
Ispunct (c) True if C is a punctuation mark.
Isspace (c) True if C is a white-space character.
Isupper (c) True if C is an uppercase letter.
Isxdigit (c) True if it is a C hexadecimal number.
ToLower (c) If C capital letter, return its lowercase letter form, otherwise directly return C.
ToUpper (c) If C is a lowercase letter, it returns its uppercase form, otherwise it returns C directly.

Most return 0 indicates success

C + + Primer Note 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.