toupper和tolower的返回值是int型值
如题,C++中函数库<cctype>定义了函数toupper和tolower,需要注意的是它们的返回值是int型的。直接上程序
(为使得转换后显示大写或者小写的字符,应该采用下述的2方法,一个是用char字符接收,一个是用类型的强制转换)
#include<iostream>
#include<string>
using namespace std;
int main()
{
char c= toupper('a');
cout<< c;
cout<<endl;
cout<< static_cast<char>(toupper('a'));//类型的强制转换。
cout<<endl;
cout<< toupper('a');//toupper 和tolower返回的int型的值。即‘a’返回ascII值65
return 0;
}