关于比较输入两个数并输出最大值的C语言问题 (在VS2012下运行)#include "stdafx.h"int _tmain(int argc,_TCHAR* argv[]){\x09int max(int x,int y);\x09int a,b,c;\x09scanf("%d,%d",&a,&b);\x09c=max(a,b);\x09printf("max=%d\n",c);\x09r
来源:学生作业帮助网 编辑:作业帮 时间:2024/06/20 16:43:56
![关于比较输入两个数并输出最大值的C语言问题 (在VS2012下运行)#include](/uploads/image/z/8716419-27-9.jpg?t=%E5%85%B3%E4%BA%8E%E6%AF%94%E8%BE%83%E8%BE%93%E5%85%A5%E4%B8%A4%E4%B8%AA%E6%95%B0%E5%B9%B6%E8%BE%93%E5%87%BA%E6%9C%80%E5%A4%A7%E5%80%BC%E7%9A%84C%E8%AF%AD%E8%A8%80%E9%97%AE%E9%A2%98+%EF%BC%88%E5%9C%A8VS2012%E4%B8%8B%E8%BF%90%E8%A1%8C%EF%BC%89%23include+%22stdafx.h%22int+_tmain%28int+argc%2C_TCHAR%2A+argv%5B%5D%29%7B%5Cx09int+max%28int+x%2Cint+y%29%3B%5Cx09int+a%2Cb%2Cc%3B%5Cx09scanf%28%22%25d%2C%25d%22%2C%26a%2C%26b%29%3B%5Cx09c%3Dmax%28a%2Cb%29%3B%5Cx09printf%28%22max%3D%25d%5Cn%22%2Cc%29%3B%5Cx09r)
关于比较输入两个数并输出最大值的C语言问题 (在VS2012下运行)#include "stdafx.h"int _tmain(int argc,_TCHAR* argv[]){\x09int max(int x,int y);\x09int a,b,c;\x09scanf("%d,%d",&a,&b);\x09c=max(a,b);\x09printf("max=%d\n",c);\x09r
关于比较输入两个数并输出最大值的C语言问题 (在VS2012下运行)
#include "stdafx.h"
int _tmain(int argc,_TCHAR* argv[])
{
\x09int max(int x,int y);
\x09int a,b,c;
\x09scanf("%d,%d",&a,&b);
\x09c=max(a,b);
\x09printf("max=%d\n",c);
\x09return 0;
}
int max(int x,int y)
{
\x09int z;
\x09if (x>y) z=x;
\x09else z= y;
\x09return z;
}
1>------ 已启动生成:项目:ConsoleApplication4,配置:Debug Win32 ------
1> ConsoleApplication4.cpp
1>c:\users\lenovo\documents\visual studio 2012\projects\consoleapplication4\consoleapplication4\consoleapplication4.cpp(11):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.
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\stdio.h(290) :参见“scanf”的声明
关于比较输入两个数并输出最大值的C语言问题 (在VS2012下运行)#include "stdafx.h"int _tmain(int argc,_TCHAR* argv[]){\x09int max(int x,int y);\x09int a,b,c;\x09scanf("%d,%d",&a,&b);\x09c=max(a,b);\x09printf("max=%d\n",c);\x09r
原因是Visual C++ 2012中,由于担心使用那些不进行参数检测的C库函数,会造成内存异常,微软改写了同样功能的函数,使这些新的函数(就是那些带有"_s”后缀的函数)更安全.
可以用新的安全函数(如scanf_s)替换原来的旧函数(如 scanf).