1、strstr(source,des)该函数返回的是des在source中首次出现的位置,如果des不在source中,则返回NULL。
int main()
{
string s = "jiang";
s = s + s;
cout << s << endl;
cout << s.length() << endl;
char des[] = "angj";
if (strstr(s.c_str(), des) >= 0)
{
cout << "s obtain des" <<endl;
}
}
2、substr(start,end); 该函数是string类的方法函数,参数是起始位置和结束位置,返回string类对象的一个子串。
string s = "jiang";
string a = s.substr(0, 4);
3、strcmp(str1,str2); 该函数是C语言库函数,返回值是0或-1或1,根据ASCII码值比较字符大小。
4、strcpy(str1,str2); 该函数是字符串复制函数。