首页 > 代码库 > C++修改字符串

C++修改字符串

#include <iostream>#include <string>using namespace std;int main(){    string s1 ;    s1 = "1234567890";    for(int i=0; i<s1.length(); i++)        cout<<s1[i]<<" ";    cout<<endl;    s1[5] = ‘5‘;    cout<<s1<<endl;    return 0;}

  输出123455789

C++修改字符串