标签:
// Example3.cpp : 定义控制台应用程序的入口点。 #include "StdAfx.h" #include <string> #include <iostream> using namespace std; int main(void) { string str,str1,str2; int index; //推断截取的子串是否由blanks组成 str=" cjc is a master."; str1="cjc is a master."; index=str.find("cjc"); str.assign(str.c_str(),index); if(str.find_first_not_of(" ")==-1) { cout<<"The string is constructed of blanks..."<<endl; } else { cout<<str<<endl; } //在字符串中插入子串 index=str1.find("master"); str2=str1.substr(index); str1.assign(str1.c_str(),index); str=str1+"good "+str2; cout<<str<<endl; system("pause"); return 0; }
标签:
原文地址:http://www.cnblogs.com/mengfanrong/p/5154837.html