相同的代码并没有在我自己的项目中编译 [英] Same code doesn't compile in my own project
问题描述
大家好,
我从老师那里得到的项目非常完美。
The projects i got from my teacher work perfect.
当我在计算机上创建一个新项目时并使用相同的代码,它不会编译。
When i create a new project on my computer and use the same code, it doesn't compile.
它会出现此错误:严重性  代码    描述    项目    文件    线   抑制状态
错误   C4996   'strcpy':此函数或变量可能不安全。请考虑使用strcpy_s。要禁用弃用,请使用_CRT_SECURE_NO_WARNINGS。有关详细信息,请参阅在线帮助。
It gives this error : Severity Code Description Project File Line Suppression State
Error 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.
我更改了编译器设置以使它们相等,这没有帮助。我还试图从我从老师那里得到的项目中创建一个项目属性文件,并将其添加到我自己的项目中。这也无济于事。
I changed compiler settings so they were equal, this didn't help. I also tried to make a project property file from the project i got from my teacher and add it to my own project. Also this didn't help.
任何人都可以帮我这个吗?
Anybody can help me with this?
这是代码:
#include< stdio.h>
#include< string.h>
$
int main(无效)
{
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\\\
",strlen(s1),strlen(s2));
printf(&de; functie strcmp(s1,s2)geeft%d als functiewaarde \ n",strcmp(s1,s2));
getchar();
返回0;
}
#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;
}
推荐答案
朋友,
感谢您发帖。
你创建了VS中的哪个项目?请确保它是控制台应用程序。
Which project in VS did you create? Please make sure it's a Console application.
我创建了下面的项目,并测试了您的代码然后它运行良好我的一面:
I created the project below, and tested your code then it run fine my side:
,代码和结果如下所示:
and the code and result shown below:
如果需要,我可以与您分享项目。
I could share the project with you if you need it.
让我知道它是否有效。
Let me know if it works.
祝你好运,
Fletcher
这篇关于相同的代码并没有在我自己的项目中编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!