![](/img/trans.png)
[英]the isupper(), islower(), toupper(), tolower() functions not working in c++
[英]Isupper / tolower doesn't work
这是问题,我的程序不会将大写字母更改为小写字母。 我不知道为什么不这样做。
#include <iostream>
#include <ctype.h>
using namespace std;
int main(){
string str="hEhEhehe";
for(int i=0;i<str.size();i++){
if(isupper(str.at(i)))
tolower(str.at(i));
}
cout << str;
return 0;
}
您需要将值分配回字符串的索引。
if(isupper(str.at(i)))
str[i] = tolower(str.at(i));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.