#include <iostream>
#include<string>
using namespace std;
int main()
{
string str="hello world";
for(string::iterator it=str.begin();it!=str.end();++it)
printf("%c",*it);
}
用迭代器(类似于指针)访问字符串
最新推荐文章于 2025-12-06 09:52:47 发布
本文展示了如何使用C++的基本语法,包括iostream库,string类型和迭代器,实现一个简单的程序,遍历并打印字符串helloworld
613

被折叠的 条评论
为什么被折叠?



