#include <iostream>
using namespace std;
#include <string>
void test01()
{
string str1 = "hello";
//[]s
for (int i = 0; i<str1.size(); i++)
{
cout << str1[i] << " ";
}
//at
cout << endl;
for (int i = 0;i< str1.size(); i++)
{
cout << str1.at(i) << " ";
}
cout << endl;
str1[0] = 'x';
cout << str1<<endl;
str1.at(0) = 'g';
cout << str1 << endl;
}
int main()
{
test01();
system("pause");
return 0;
}
网友评论