日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Stack around the variable 'date' was corrupted.

發布時間:2023/12/20 编程问答 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Stack around the variable 'date' was corrupted. 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

為什么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.的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。