为什么80%的码农都做不了架构师?>>>   

代码如下:

#include <stdio.h>

#include <Windows.h>

// in 64 win7 vs2010...here    have to define a 8s' space.. so defined e00_date.wee

struct e00_date{

unsigned short int year;

unsigned short int month;

unsigned short int day;

//unsigned char tt;

//unsigned short week;

};

typedef struct e00_date e00_date;

void main()

{

e00_date date;

unsigned short int sum=0;

puts("input a date (format: yyyy/mm/dd)");

scanf("%d/%d/%d",&date.year,&date.month,&date.day);

if(date.month>12||date.month<1)

{

puts("please input a viald value");

system("pause");

exit(0);

}

sum+=date.day;

switch(date.month)

{case 12: sum+=30;

case 11: sum+=31;

case 10: sum+=30;

case 9: sum+=31;

case 8: sum+=31;

case 7: sum+=30;

case 6: sum+=31;

case 5: sum+=30;

case 4: sum+=31;

case 3: sum+=28;

case 2: sum+=31;

case 1: break;

}

if(((date.month%4==0)&&(date.month%100!=0))||(date.month%400==0))

if(date.month>2)

sum++;

printf("\nthis the %hu days in %4hu/%02hu/%02hu(yyy/mm/dd)",sum,date.year,date.month,date.day); system("pause");

}

#################################################

今天遇到一个错误如题,在程序结尾来了这么一下。

解决方法一:

但是在struct e00_date里面在加一个char或者 short。就正常了(struct 注释的2个变量),添加变量是为了使struct的size大>=8,64位的系统,所以猜想是这里有问题?!但是没道理啊,其他2,4,6大小的struct都没问题。。

解决方法二:

网上找,都说是越界了。。然后debug一个一个找,数据都能正确的存到变量里。后面没办法了,一个一个的格式化输入输出,

scanf那,把%d改成%hu,最终就OK了。还是很纳闷。。程序运行到system("pause");最后面了,才报错,前面都过的去,怎么这里这么就出来了。。(1.这里都没有访问数据读取了。怎么出现错误。2.存储空间数据也是正确存入了,也就是说在short的2个字节范围内没有异常数据。它凭什么就被corrupted。就算输入1998/9/25(0x07ce/0x0009/0x0019)可能会变成(0x000007ce,0x00000009,0x00000019)最多就是把2个字节以外的0丢失嘛。。

真心搞不通啊。是不是理解有错~~求解释~~~~~

转载于:https://my.oschina.net/singlem1905/blog/82937

Stack around the variable 'date' was corrupted.相关推荐

  1. 有关Run-Time Check Failure #2 - Stack around the variable 'XXX' was corrupted.错误的解决方法

    有关Run-Time Check Failure #2 - Stack around the variable 'XXX' was corrupted.错误的解决方法 今天我在敲完一段代码运行的时候出 ...

  2. C error :Run-Time Check Failure #2 - Stack around the variable 'b' was corrupted.

    运行程序遇到这样的错误:Run-Time Check Failure #2 - Stack around the variable 'b' was corrupted. 检查后发现原因在于:数组b越界 ...

  3. Run-Time Check Failure #2 – Stack around the variable 'a' was corrupted.

    Run-Time Check Failure #2 – Stack around the variable 'a' was corrupted. 今天在用VS调代码的时候,会出现这个问题,经过查找以及 ...

  4. C语言,一个分号引发的问题:Run-Time Check Failure #2 - Stack around the variable ‘class1‘ was corrupted.

    上课时做de一个案例如上图 函数是这样的,并没有问题 void score(float s[], int num) {float avg, max=s[0];float sum = 0;int i = ...

  5. c语言变量周围堆栈损坏csdn,围绕变量“输入”的堆栈已损坏(Stack around the variable 'input' was corrupted)...

    围绕变量"输入"的堆栈已损坏(Stack around the variable 'input' was corrupted) 我刚开始使用C语言,但遇到了这个错误. 我试图在网上 ...

  6. Run-Time Check Failure #2 Stack around the variable ‘xxx’ was corrupted

    在改别人代码时,运行报错: Run-Time Check Failure #2 Stack around the variable 'buffer' was corrupted 这表明你对某变量的赋值 ...

  7. VS2010中“Stack around the variable 'XXX' was corrupted.”处理方法

    1 问题引入 VS2010中基于控制台的Win32程序,输出正常,当关闭程序后,会弹出错误对话框,显示"Stack around the variable 'XXX' was corrupt ...

  8. Run-Time Check Failure #2 - Stack around the variable 'a' was corrupted 解决方法

    一.数据越界 vc++ 2008调试过程说:Run-Time Check Failure #2 - Stack around the variable 'a' was corrupted.下面为被调试 ...

  9. 发生异常错误Stack around the variable 'XXX' was corrupted

    vs2019下,程序结果能出来,但是出现Run-Time Check Failure #2 - Stack around the variable 'XXX' was corrupted. 原因: S ...

最新文章

  1. php获取另一个php页面_post值,php接受post传值的方法
  2. python3.6执行pip3时 Unable to create process using ''
  3. 深入理解CRITICAL_SECTION
  4. RecyclerView的ItemAnimator
  5. 在windows下安装node-sass失败,提示\node-sass: Command failed,解决方案
  6. 2021应届生DJI校招在线测评几点说明
  7. 如何access表中加一行_access数据库增加一行
  8. SystemUI 锁屏点击通知解锁界面重叠(bouncer界面与锁屏第一界面)
  9. 面试题19/leetcode10:正则表达式匹配 C++
  10. python语法简单吗_python基本语法练习实例 python好学吗? 语法简单吗? 举个例子?...
  11. 计算机经典书籍介绍及下载站点
  12. 门面(facade)模式
  13. QtCreator 忽略指定警告
  14. 我为什么加入了 TDengine
  15. 绝地求生手游电脑版连接服务器没有响应,绝地求生电脑版进去为什么连接失败 | 手游网游页游攻略大全...
  16. Java中实例化对象是什么意思
  17. 学微服务必经之路——Nacos新手入门(上)
  18. appium java环境_Appium java 环境配置
  19. 风险管理中决策树理论与案例
  20. 东北大学计算机专业(专业硕士)研究生入学考试2009真题

热门文章

  1. 图的存储之链式前向星
  2. 关于盘符里某些文件夹删除不了的解决方案研究
  3. python机器学习入门(Day1:Numpy)
  4. 《Android 应用案例开发大全(第二版)》——6.1节Android系统的信使:Intent
  5. 【oracle】关于处理小数点位数的几个oracle函数
  6. Linux 应用程序开发入门
  7. HTML 静态网页制作12月2日表单样式
  8. 推荐一款生成SQL插入语句的软件
  9. psql: FATAL: role “appleyuchi” does not exist与修改默认密码
  10. 淘宝上的所有cuda书籍调研