why g++ shows “gets()” not declared ,even after including

后端 未结 2 1403
我寻月下人不归
我寻月下人不归 2021-01-28 21:33
#include 
#include 
#include 

using namespace std;

int main()
{
    char str[30];
    gets(str);
}

when

2条回答
  •  既然无缘
    2021-01-28 22:00

    gets was deprecated in C++11 and removed from C++14. If you are using GCC6.0 or newer then by default it uses C++14 and won't be available. Instead of using

    main()
    {
        char str[30];
        gets(str);
    }
    

    use

    int main()
    {
        std::string str;
        std::getline(cin, str);
    }
    

提交回复
热议问题