1. 程式人生 > >[C++/STL] string字串關於copy函式的C4996錯誤

[C++/STL] string字串關於copy函式的C4996錯誤

今天晚上,在使用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 ;

特在此記錄,希望遇到同樣錯誤不能解決的學友們可按此方法解決;