string s19 = "hello, world!";
for(auto c: s19)
{
//输出大写形式
if(!ispunct(c) || !isspace(c))
{
cout << toupper(c);
}
}
这样写打印时是一串数字。而如果像下面这样:
c = toupper(c);
cout << c;
打印时则正确,请问大家这是怎么回事?
string s19 = "hello, world!";
for(auto c: s19)
{
//输出大写形式
if(!ispunct(c) || !isspace(c))
{
cout << toupper(c);
}
}
这样写打印时是一串数字。而如果像下面这样:
c = toupper(c);
cout << c;
打印时则正确,请问大家这是怎么回事?
3 回答1.3k 阅读✓ 已解决
1 回答1k 阅读✓ 已解决
4 回答807 阅读
1 回答880 阅读
1 回答910 阅读
1 回答679 阅读
1 回答786 阅读
原因很简单。
请注意
toupper
的返回值:http://www.cplusplus.com/reference/cctype/toupper/