gets导致编译失败,并出现“使用未声明的标识符'gets'”错误

问题描述

我正在尝试解决e问题。我将字符作为输入并使用gets()。但是该函数显示了上述错误。

我不知道为什么此功能行为异常。请帮我找出故障。我是初学者。

如前所述,错误消息是:

Use of undeclared identifier 'gets'

我的C ++代码:

#include <bits/stdc++.h>
using namespace std;

int main()
{
    char line[1000];
    bool open = true;
    while (gets(line))  //***in this line gets() is showing error***
    {
        int len = strlen(line);
        for (int i = 0; i < len; i++)
        {
            if (line[i] == '"')
            {
                if (open)
                {
                    printf("``");
                }
                else
                {
                    printf("''");
                }
                open = !open;
            }
            else
            {
                printf("%c",line[i]);
            }
        }
        printf("\n");
    }

    return 0;
}

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)