/tmp/compiler_u7rkr4xd/src: 在函数‘int main()’中:
/tmp/compiler_u7rkr4xd/src:7:2: 错误:‘gets’ was not declared in this scope; did you mean ‘fgets’?
7 | gets(x);
| ^~~~
| fgets
/tmp/compiler_u7rkr4xd/src:8:15: 警告:comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare]
8 | for(int i=0;i<strlen(x);i++)
| ~^~~~~~~~~~
报错内容(在洛谷里 c++编译器里没报错 以下代码
#include<bits/stdc++.h>
using namespace std;
int main(){
//string x;
char x[1000];
int l=0,d=0,o=0;
gets(x);
for(int i=0;i<strlen(x);i++)
{
if(x[i]>='a'&&x[i]<='z')
{
l++;
//cout<<x[i]<<"是字母"<<endl;
}
else if(x[i]>='0'&&x[i]<='9')
{
d++;
//cout<<x[i]<<"是数字"<<endl;
}
else
{
if(x[i]!=' ')
o++;
//cout<<x[i]<<"是其他"<<endl;
}
}
cout<<"Letters="<<l<<endl;
cout<<"Digits="<<d<<endl;
cout<<"Others="<<o-1;
return 0;
}