[C++/STL] string字串關於copy函式的C4996錯誤
阿新 • • 發佈:2019-02-12
今天晚上,在使用Visual Stdio 2013使用string類的copy函式時,編譯出現以下錯誤:
error C4996: 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>::copy': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators'
解決辦法:
右鍵專案-->屬性--> 【通用配置】/【c/c++】/ 【前處理器】中第一行 【前處理器定義】中右邊點選編譯 ,在最下方加入_SCL_SECURE_NO_WARNINGS 確定即可;
注意: 新增的是_SCL_SECURE_NO_WARNINGS 去掉提示錯誤-D_SCL_SECURE_NO_WARNINGS前面的-D ;