标签:style blog http io os ar sp div 2014
// Example3.cpp : 定义控制台应用程序的入口点。
//以特定单词为分界,求取字符串的左右子串
#include "StdAfx.h"
#include <string>
#include <iostream>
using namespace std;
int main(void)
{
string str,str1,str2;
int index;
str="cjc is a good boy";
cout<<"The original string is \""<<str<<"\"."<<endl;
index=str.find("good");
str2=str.substr(index);
str1=str.assign(str.c_str(),index);
cout<<"The left string is \""<<str1<<"\"."<<endl;
cout<<"The right string is \""<<str2<<"\"."<<endl;
system("pause");
return 0;
}
C++ string类取字符串的左右子串(以特定子串为分界限)
标签:style blog http io os ar sp div 2014
原文地址:http://www.cnblogs.com/mengfanrong/p/3996291.html