C++ 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");
}

浙公网安备 33010602011771号