读书人

求热心人指教

发布时间: 2013-06-25 23:45:41 作者: rapoo

求好心人指教
#include <iostream>
using namespace std;
char changeChar(char temp)
{
temp='temp'-'A'+'a';
cout<<"转化后的字母是:"<<temp<<endl;
return temp;
}
int main()
{
char temp;

cout<<"请输入一个小写字母:"<<endl;
cin>>temp;
cout<<"输出刚才输入的字母:"<<temp<<endl;
changeChar(temp);
return 0;
}为什么这个程序不能讲一个小写字母转换为大写字母
[解决办法]
小写字母转换为大写字母
不应该是
temp='temp'-'A'+'a';
而应该是
temp=temp-'a'+'A';

读书人网 >C++

热点推荐