3

3.2 Library string Type

3.2.1 Defining and Initializing strings
string s1;                      Default initialization; s1 is the empty string.
string s2 = s1;                 s2 is copy of s1
string s3 = "hydra";            s3 is copy of the string literal
string s4(10, 'c');             Initialize s4 with n copies of the character 'c'
3.2.2 Operation on strings
os << s         Write s onto output stream os. Returns os.
is >> s         Reads whitespace-separated(e.g., space, newlines, tabs) string from is into s. Returns is.
getline(is, s)  Reads a line of input from is into s. Returns is.
3.2.3 Dealing with the Characters in a string
isalnum(c)  true if c is a letter or a digit
isalpha(c)  true if c is a letter
iscntrl(c)  true if c is a control character
isdigit(c)  true if c is a digit
isspace(c)  true if c is whitespace(i.e., a space, tab, vertical tab, return, newline, or formfeed)
isupper(c)  true if c is an uppercase letter
isxdigit(c)  true if c is a hexadecimal digit.
tolower(c)  if c is an uppercase letter, returns its lowercase; otherwise return c unchanged.
toupper(c) if c is an lowercase letter, returns its uppercase; otherwise return c unchanged.

3.3 Library vector Type

3.3.1 Defining and Initializing strings
vector v1              vector that holds objects of type T. Default initialization; v1 is empty
vector v2(v1)          v2 has a copy of each element in v1
vector v2=v1           Equivalent to v2(v1), v2 is a copy of the elements in v1
vector v3{n, val}      v3 has n elements with value val
vector v4{n}           v4 has n copies of a value-initialized object
vector v5{a,b,c...}    v5 has as many elements as there are initializers
vector v5={a,b,c...}   Equivalent to v5{a,b,c...}
3.3.2 Adding Elements to a vector
push_back

Key Concept:

你可能感兴趣的:(3)