解决VS2017中出现'strcpy': This function or variable may be unsafe. Consider using strcpy_s inst

当运行C++程序时,出现下面错误:

1>------ Build started: Project: Windows 编程, Configuration: Debug Win32 ------

1>  Source.cpp

1>d:\personal\documents\visual studio 2013\projects\windows 编程\windows 编程\source.cpp(42): error C4996: 'strtok': This function or variable may be unsafe. Consider using strtok_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

1>          d:\program files (x86)\microsoft visual studio 12.0\vc\include\string.h(204) : see declaration of 'strtok'

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

解决方法:

找到【项目属性】,点击【C++】里的【预处理器】,对【预处理器】进行编辑,在里面加入一段代码:_CRT_SECURE_NO_WARNINGS。

图示:

解决VS2017中出现'strcpy': This function or variable may be unsafe. Consider using strcpy_s inst

解决VS2017中出现'strcpy': This function or variable may be unsafe. Consider using strcpy_s inst 点击小箭头然后再点击编辑,如下图:

解决VS2017中出现'strcpy': This function or variable may be unsafe. Consider using strcpy_s inst

添加上这句话: _CRT_SECURE_NO_WARNINGS。然后点击确定在运行就可以了。

上一篇:strtok()函数介绍


下一篇:V2019编写C/C++时没有与参数列表匹配的重载函数实例