参考博客http://blog.csdn.net/zmqblog/article/details/20069103
#include <stdlib.h> atoi函数把字符串转换成整型数。其含义是ASCII to integer 的缩写。
函数原型 int atoi(const char *nptr);
该博客中有更加详细的用法。
#include <string.h>
strstr函数
https://baike.baidu.com/item/strstr/811469?fr=aladdin
substr函数
字符串str2 = "how are you",想将are拷贝到str1
string str2 = "how are you";
string str1=str2.substr(4,3);
4为开始位置,3为长度
string
C++中的
string类中有erase成员函数,其功能是删除字符串中的字符或字符串。
该成员函数的原型为
string erase(int start, int len); //start为要删除字符的起始位置(从0数起),len为要删除字符的个数。
例如:
...
#include<string>
using namespace std;
...
string s1="asdfgh", s2;
s2=s1.erase(2,3); //删除s1中从第2个字符其的3个字符。
则s2的内容为"ash"