[英]same code doesn't work on my own project (strcpy) in visual studio 2017
I'm working on some exercises for school.我正在为学校做一些练习。 The projects i have from my teacher work without any errors.
我从老师那里得到的项目没有任何错误。 When i copy the code to a new project made on my computer, it shows this error: Compiler Warning (level 3) C4996
当我将代码复制到计算机上创建的新项目时,它显示此错误:编译器警告(级别 3)C4996
I looked at both compiler settings and made them equal, this didn't work.我查看了两个编译器设置并使它们相等,这不起作用。 So i tried to make a project property file from my teachers project and insert it into my own project.
所以我试图从我的老师项目中制作一个项目属性文件并将其插入到我自己的项目中。 Also this doesn't work.
这也不起作用。 Can somebody help me solving this issue?
有人可以帮我解决这个问题吗? This is the code:
这是代码:
#include <stdio.h>
#include <string.h>
int main(void)
{
char s1[32];
char s2[32];
strcpy(s1, "abc def.");
strcpy(s2, "ghi_x");
printf("s1=\"%s\" en s2=\"%s\"\n", s1, s2);
printf("s1 bevat %d symbolen en s2 bevat %d symbolen\n", strlen(s1), strlen(s2));
printf("De functie strcmp(s1,s2) geeft %d als functiewaarde\n", strcmp(s1, s2));
getchar();
return 0;
}
The Error I get is我得到的错误是
Severity Code Description Project File Line Suppression State Error C4996 'strcpy': This function or variable may be unsafe.
严重性代码说明项目文件行抑制状态错误 C4996“strcpy”:此函数或变量可能不安全。 Consider using strcpy_s instead.
考虑使用 strcpy_s 代替。 To disable deprecation, use _CRT_SECURE_NO_WARNINGS.
要禁用弃用,请使用 _CRT_SECURE_NO_WARNINGS。 See online help for details
详情请参见在线帮助
A quick Google search shows that "Compiler Warning (level 3) C4996" means you're using deprecated functions.快速谷歌搜索显示“编译器警告(级别 3)C4996”意味着您正在使用不推荐使用的函数。 The most likely culprits are your
str*
functions since they are generally unsafe.最有可能的罪魁祸首是您的
str*
函数,因为它们通常是不安全的。 Switch to using their strn*
counterparts (eg strncpy
).切换到使用它们的
strn*
对应项(例如strncpy
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.