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

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

Stack around the variable 'date' was corrupted.

發(fā)布時(shí)間:2023/12/20 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Stack around the variable 'date' was corrupted. 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

為什么80%的碼農(nóng)都做不了架構(gòu)師?>>> ??

代碼如下:

#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");

}

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

今天遇到一個(gè)錯(cuò)誤如題,在程序結(jié)尾來(lái)了這么一下。

解決方法一:

但是在struct e00_date里面在加一個(gè)char或者 short。就正常了(struct 注釋的2個(gè)變量),添加變量是為了使struct的size大>=8,64位的系統(tǒng),所以猜想是這里有問(wèn)題?!但是沒(méi)道理啊,其他2,4,6大小的struct都沒(méi)問(wèn)題。。

解決方法二:

網(wǎng)上找,都說(shuō)是越界了。。然后debug一個(gè)一個(gè)找,數(shù)據(jù)都能正確的存到變量里。后面沒(méi)辦法了,一個(gè)一個(gè)的格式化輸入輸出,

scanf那,把%d改成%hu,最終就OK了。還是很納悶。。程序運(yùn)行到system("pause");最后面了,才報(bào)錯(cuò),前面都過(guò)的去,怎么這里這么就出來(lái)了。。(1.這里都沒(méi)有訪問(wèn)數(shù)據(jù)讀取了。怎么出現(xiàn)錯(cuò)誤。2.存儲(chǔ)空間數(shù)據(jù)也是正確存入了,也就是說(shuō)在short的2個(gè)字節(jié)范圍內(nèi)沒(méi)有異常數(shù)據(jù)。它憑什么就被corrupted。就算輸入1998/9/25(0x07ce/0x0009/0x0019)可能會(huì)變成(0x000007ce,0x00000009,0x00000019)最多就是把2個(gè)字節(jié)以外的0丟失嘛。。

?

真心搞不通啊。是不是理解有錯(cuò)~~求解釋~~~~~

?

轉(zhuǎn)載于:https://my.oschina.net/singlem1905/blog/82937

總結(jié)

以上是生活随笔為你收集整理的Stack around the variable 'date' was corrupted.的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。