string::at

char& at (size_t pos);
const char& at (size_t pos) const;

#include <string>
#include <iostream>

using namespace std;
int main()
{
string s1("test");
for(unsigned int i = 0; i < s1.length(); ++ i)
{
cout << s1.at(i) << " ";
}
cout << endl;
return 0;

原文地址:https://www.cnblogs.com/xpylovely/p/12082427.html