gpt4 book ai didi

c++ - 我在 C++ 中使用 tolower() 时遇到问题

转载 作者:行者123 更新时间:2023-11-27 23:57:16 24 4
gpt4 key购买 nike

<分区>

当我尝试在字符串上使用 tolower,而不是将字母变为小写时,程序会将它们转换为随机符号。这是我的代码:

#include <iostream>
#include <locale>
using namespace std;

int main()
{
string hi= "thTSMSdjNnJlJjnJJKn";
for (int i=0; i<hi.length(); i++)
{
hi[i]+=tolower(hi[i]);
cout << hi[i];
}
}

这是输出:Þð╚ã║ã╚È╝▄┤Ï┤È▄┤┤Â▄

它有什么问题?这不是我想要使用 tolower 的实际代码,但我只是将它放在一个单独的示例中,这样它就更清楚了。我也不介意使用大写,但主要的是我让字符串中的所有字母大小写相同。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com