C++ 循环for 引用 for(string & : )
Posted 软件工程小施同学
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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;
}
https://blog.csdn.net/weixin_43972675/article/details/104070590
以上是关于C++ 循环for 引用 for(string & : )的主要内容,如果未能解决你的问题,请参考以下文章
C++初阶第三篇——初始C++(引用+内敛函数+auto关键字+范围for循环)