花豹与狮子:C++,请改正!!!!

来源:百度文库 编辑:高考问答 时间:2024/05/07 03:55:11
程序‘转换大小写’:
#include<iostream>
#include<cctype>
using namespace std;
int main(){
cout<<"input some:";
char chr[80];
cin>>chr;
char *p;
p=chr;
while(*p){
if(isupper(*p))
*p=tolower(*p);
else if(islower(*p))
*P=toupper(*p);
p++;
}
cout<<"after change:"<<chr<<'\n';;
return 0;
}
提示while中的p未定义?????

else if(islower(*p))
*P=toupper(*p); //*P拼写错误了,应该是小写的*p