0
点赞
收藏
分享

微信扫一扫

C++ 循环for 引用 for(string & : )

#include <iostream>
using namespace std;

int main()
{
//c++范围for语句,处理字符串中的每个字符
//将字符串中的每个小写字母转换为大写字母
string str("I can fly high!");
for(auto &c : str) //使用引用以更改字符的值
c = toupper(c);
cout<<str<<endl;
return 0;
}

举报

相关推荐

0 条评论