error C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead.

今天编写C++程序在使用头文件#include<cstring>中的strcpy()和strcat()函数时出现了一个错误:error C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead.在网上搜了一下大概知道怎么解决了,并且知道为什么出现这个错误——出现这个错误时,是因为strcpy()和strcat()函数不安全造成的溢出。
解决方法是:找到【项目属性】,点击【C++】里的【预处理器】,对【预处理器】进行编辑,在里面加入一段代码:_CRT_SECURE_NO_WARNINGS。

 


这样就解决了。

posted @ 2021-03-05 00:47  liweikuan  阅读(175)  评论(0编辑  收藏  举报