警告 1 warning C4996: ‘strcpy’: This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.c:\users\administrator\desktop\temp\string test3\test\test\main.cpp13
test
#include<stdio.h>
#include "malloc.h"
#include<string.h>
#define null 0
void copy_string(char **p,int num)
{
*p=(char*)malloc(num);
}
int main(void)
{
char *str=null;
copy_string(&str,100);
strcpy(str,"hello");
printf("%s",str);
while(1);
return 0;
}
解决方法:
其中之一的解决方案:
项目 ->属性 -> c/c++ -> 预处理器 -> 点击预处理器定义,编辑,加入_CRT_SECURE_NO_WARNINGS,即可。