#include
#include
#include
using namespace std;
int main()
{
char str[30];
gets(str);
}
when
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);
}
gets
is an unsafe function and is not supported by the C Standard any more.
Instead use fgets.
For example
#include <iostream>
#include <cstdio>
#include <cstring>
int main()
{
char str[30];
std::fgets(str, sizeof( str ), stdin );
str[ std::strcspn( str, "\n" ) ] = '\0';
//...
}