天天看点

string类assign方法

#include <string>

#include <iostream>

using namespace std;

int main()

{

string str1c ( "Hello " ), str2c ( "WideeWorld" );

str1c.assign ( str2c , 5 , 3 );//将str2c字符串从第5位开始往后3位赋值给str1;

cout<<str2c<<endl;//输出结果为WideeWorld

cout<<str1c<<endl;//输出结果为Wor

system("pause");

}

本文转自 韬光星夜 51CTO博客,原文链接:http://blog.51cto.com/xfqxj/512018,如需转载请自行联系原作者

继续阅读