C++_Sting的操作

【1】string子串:
str.substr(0,i_start);//取从0下标开始的i_start个字符
cout<<x.substr(5)<<endl;//截取x[5]到结尾,即npos.重载原型为string substr(_off,_count=npos)  

【2】atoi函数把字符串转换成整型数

 char a[] = "-100" ;
  char b[] = "123" ;
  int c ;
  c = atoi( a ) + atoi( b ) ;

【3】erase参数:起始位置,删除长度。

 strT.erase(pos,2)

[4]string.find()

https://blog.csdn.net/shujh_sysu/article/details/52026108




猜你喜欢

转载自blog.csdn.net/m0_38034312/article/details/80056598
今日推荐