P5733自动修正
上一次做用了strupr,CE了,听从了大佬的意见:Linux用不了strupr。这回定了一个函数,在DevC++中调试成功了,然而提交后……
/tmp/compiler_3r2t8zsq/src: 在函数‘int main()’中:
/tmp/compiler_3r2t8zsq/src:13:9: 错误:cannot bind non-const lvalue reference of type ‘char*&’ to an rvalue of type ‘char*’
13 | strupr(a);
| ^
/tmp/compiler_3r2t8zsq/src:4:20: 附注: 初始化‘void strupr(char*&)’的实参 1
4 | void strupr(char* &e){
| ~~~~~~~^
代码如下:
#include<iostream>
#include<cstring>
using namespace std;
void strupr(char* &e){
int b=strlen(e);
for(int i=0;i<b;i++){
if(e[i]>='a'&&e[i]<='z') e[i]+=32;
}
}
int main(){
char a[105];
cin>>a;
strupr(a);
cout<<a;
return 0;
}