作者hyestt (小杰)
看板C_and_CPP
标题[问题] 附程式 请帮我看bug
时间Thu Jul 9 19:20:34 2009
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cctype>
using namespace std;
int main()
{
cout<<"start";
cin.get();
char ch;
cin.get(ch);
while(ch!='@')
{
if(!isdigit(ch))
{
if(isupper(ch))
cout<<tolower(ch);
else if(islower(ch))
cout<<toupper(ch);
else
cout<<ch;
}
else
cin.get(ch);
}
}
我希望能输入随意的字母
输出"大小写互换"且"数字无法读入"的字母,直到按下'@'就会终止
不过这是我出现的结果
start
xc xzcvzxc ZXDCVXZV @DCFVMC;X
8867 88906786908867 12212010099118120122118
结果输出全变成数字了QQ
请问bug在哪呢?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.114.14.246
1F:→ akasan:tolower, toupper回传的是int 07/09 20:52
2F:→ hyestt:那我该怎麽改才能变成字母 07/09 21:01
3F:推 gozha:cout << (char)(tolower(ch)); 07/09 22:09