3

作者: hshg | 来源:发表于2022-05-13 09:17 被阅读0次

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

Key Concept:

相关文章

  • 恶意文件夹

    【%你的iapp在这里哦/恭喜你找到了/3/3/3/3/3/3/3/3/3/3/3/3/3/3/3/3/3/3/3...

  • 3+3+3

    九年了,不曾去过,马路那边的刘家村。唱戏,小路~抓蝌蚪,洗衣服,捞水草,漩涡~种满菜的田地,养着奶牛的茅草屋,充满...

  • 3/3

    郭一博 刘佐千 李文浩 王天聪 柳絮 刘全利 李明东

  • 3/3

  • if(a==3) or if(3==a)

    记得刚写程序那会儿,遇到 if else 的条件判断逻辑,基本都会这样写:if(a==3) 为什么呢? 因为自然...

  • 3/3

    原先我是为了他留长头发,现在他的女朋友剪了短发,他说随她去,都好。 原先她卑微付出真心为他,现在她是个被宠溺的幸福...

  • 3/3

    夜月再至,只剩着静谧和四寂与我作伴, 呼啸而过,耳畔又闻过车马还川流不息, 旧亿渐入,也始终囚于泯然其细枝末节。 ​​​

  • 3:3

    今天是个晴朗的天气。染俄我只想呆在寝室。

  • 美惠教练3  3  3  3

  • 做乘法的意义练习时的问题

    4×3 4+3 4×4×4 4+4+4 3+3+3+3 3×3×3×3 2×3 3×3 第一单元要学完了,通过测评

网友评论

      本文标题:3

      本文链接:https://www.haomeiwen.com/subject/ppteurtx.html