string s19 = "hello, world!"; for(auto c: s19) { //输出大写形式 if(!ispunct(c) || !isspace(c)) { cout << toupper(c); } } 这样写打印时是一串数字。而如果像下面这样:
c = toupper(c); cout << c;
打印时则正确,请问大家这是怎么回事?
拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...
The reason is simple.
Please note the return value of toupper: http://www.cplusplus.com/reference/cctype/toupper/
toupper
The reason is simple.
Please note the return value of
toupper
: http://www.cplusplus.com/reference/cctype/toupper/