[英]Isupper / tolower doesn't work
here's the problem, my program does not change uppercase letter to lowercase letter. 这是问题,我的程序不会将大写字母更改为小写字母。 I can not figure out why doesn't it.
我不知道为什么不这样做。
#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;
}
You need to assign the value back to the index of the string. 您需要将值分配回字符串的索引。
if(isupper(str.at(i)))
str[i] = tolower(str.at(i));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.