c语言比较两个数中最大值和最小值,关于比较输入两个数并输出最大值的C语言问题 (在VS2012下运行)...

问题描述:

关于比较输入两个数并输出最大值的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”的声明

1个回答

分类:

综合

2014-12-10

问题解答:

我来补答

原因是Visual C++ 2012中,由于担心使用那些不进行参数检测的C库函数,会造成内存异常,微软改写了同样功能的函数,使这些新的函数(就是那些带有"_s”后缀的函数)更安全.

可以用新的安全函数(如scanf_s)替换原来的旧函数(如 scanf).

展开全文阅读

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值