鱼C论坛

 找回密码
 立即注册
查看: 1995|回复: 3

[已解决]被VS弄傻了帮我看看scanf函数怎么了

[复制链接]
发表于 2017-1-26 20:06:57 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. //出口条件循环

  2. #include <stdio.h>

  3. int main(void)
  4. {
  5.         const int secret_code = 3;
  6.         int code_entered;

  7.         printf("To enter the triskaidekaphobia therapy club,\n");
  8.         printf("please enter the secret code number: ");
  9.         scanf("%d",&code_entered);

  10.         while(code_entered != secret_code)
  11.         {
  12.                 printf("To enter the triskaidekaphobia therapy club,\n");
  13.                 printf("please enter the secret code number: ");
  14.                 scanf("%d",&code_entered);
  15.         }
  16.         printf("Congratulations! You are cured!\n");

  17.         getchar();
  18.         getchar();
  19.         return 0;
  20. }
复制代码
最佳答案
2017-1-26 23:42:18
VS说,scanf()函数不安全,要么,你使用scanf_s()函数,要么,就继续使用不安全的scanf()函数。
QQ图片20170126233050.png 如图,创建项目时候取消勾选安全开发生命周期(SDL)检查”,就可以使用scanf()了。网上还有很多方法:这里就不详细说了,地址如下:"http://jingyan.baidu.com/article/19020a0a39196e529d284239.html"



小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2017-1-26 23:13:00 | 显示全部楼层
程序好像没有问题呀?
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2017-1-26 23:42:18 | 显示全部楼层    本楼为最佳答案   
VS说,scanf()函数不安全,要么,你使用scanf_s()函数,要么,就继续使用不安全的scanf()函数。
QQ图片20170126233050.png 如图,创建项目时候取消勾选安全开发生命周期(SDL)检查”,就可以使用scanf()了。网上还有很多方法:这里就不详细说了,地址如下:"http://jingyan.baidu.com/article/19020a0a39196e529d284239.html"



小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2017-1-27 08:46:26 | 显示全部楼层
非常感谢楼上的解答
!!!
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-7-3 19:05

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表