更新时间:2022-06-18 08:54:00
#include "stdafx.h" #include "stdio.h" void main() { int n,x,y; printf("请输入n和x的值\n"); scanf("%d %d",&n,&x); y=n+x; printf("最后的结果是:%d\n",y); }
error C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
c:\program files\microsoft visual studio 11.0\vc\include\stdio.h(290) : 参见“scanf”的声明
原因:
原因是Visual C++ 2012 使用了更加安全的 run-time library routines 。新的Security CRT functions(就是那些带有“_s”后缀的函数),
请参见:《CRT函数的安全增强的版本》。
解决原因:
一个递归题:
// libinC.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include "stdio.h" int foo(int n, int x) { if (n == 0) return 1; if (n == 1) return x; return 2 * x * foo(n-1, x) - foo(n-2, x); } void main() { int n,x,y; printf("请输入n和x的值\n"); scanf("%d %d",&n,&x); y=foo(n,x); printf("最后的结果是:%d\n",y); }