墨启飞 2021-10-05 18:07 采纳率: 100%
浏览 639
已结题

error C3861: “gets”: 找不到标识符

请帮我看一下为怎么报错: error C3861: “gets”: 找不到标识符

img


代码:#include <iostream>

#include <cstdio>

#include <cstring>

using namespace std;



int main ()

{

char str[100];

int alpha=0,digit=0,space=0,other=0;

int n=100;

gets(str); //字符串的输入 

for(int i=0;i<strlen(str);i++)

{

if (isalpha(str[i]))

++alpha;

else if(isdigit(str[i]))

++digit;

else if(str[i]==32)

++space;

else

++other;

}

cout<<alpha<<" "<<digit<<" "<<space<<" "<<other<<endl;

return 0;

 } 
  • 写回答

3条回答 默认 最新

  • qzjhjxj 2021-10-05 18:16
    关注

    改用gets_s ()

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 10月13日
  • 已采纳回答 10月5日
  • 创建了问题 10月5日