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;
}
全部评论

相关推荐

评论
点赞
收藏
分享
牛客网
牛客企业服务