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

相关推荐

昨天 11:21
复旦大学 Java
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务