其他分享
首页 > 其他分享> > 解决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

作者:互联网

当运行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。

图示:

 点击小箭头然后再点击编辑,如下图:

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

标签:function,Consider,CRT,NO,strtok,点击,WARNINGS,strcpy,SECURE
来源: https://blog.51cto.com/u_15242250/2870232