赞
踩
string a="abcd"; 1.获取string字符串某一个字符 auto s=a.at(1); //结果为 s='b'; for (unsigned int i=0;i<a.size();i++) { cout << a.at(i) << endl; } /* 结果为 a b c d */ //等同于a[i],但是at()会有下标检查,如果超出则抛出out_of_range 2.修改string字符串某一个字符 a.at(2)='1'; //结果为 a="ab1d";
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。