C++提高教程 STL-string字符存取
# include<iostream>
# include<string>
using namespace std;
void test01()
{
string str1 = "Hello";
cout << "str1:" << str1 << endl;
for (int i = 0; i < str1.size();i++)
{
cout << str1[i] << endl;
}
cout << endl;
for (int i = 0; i < str1.size(); i++)
{
cout << str1.at(i) << endl;
}
}
int main()
{
test01();
system("pause");
return 0;
}