下面是一個簡單的C++代碼:錯誤C4996是什麼意思?
#include <cstring>
using namespace std;
int main(int argc, _TCHAR* argv[])
{
char str[80];
cout << "輸入字串:";
gets(str);
cout << "輸入的字串:" << str << endl;
return 0;
}
當編譯它,我得到以下錯誤:
"錯誤1 error C4996: 'gets': This function or variable may be unsafe.
Consider using gets_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details."
這意味着「獲取」可能是不安全的,你應該考慮使用gets_s代替。或者你可以定義_CRT_SECURE_NO_WARNINGS來禁用警告。您可以在聯機幫助的某處找到更多詳細信息,可能是通過搜索「C4996」或「獲取」。 – immibis
當我使用gets_s()函數而不是gets()。沒關係! –
'gets'是如此危險,以至於它在C和C++中都被棄用了。 –