C++ string类assign用法

来源:互联网 发布:普通车床车v型带轮算法 编辑:程序博客网 时间:2024/05/19 16:36
 
#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;//输出结果为WideeWorldcout<<str1c<<endl;//输出结果为Worsystem("pause");}