本文介绍了变量周围的堆栈已损坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
void myInvalidParameterHandler(const wchar_t* expression,
const wchar_t* function,
const wchar_t* file,
unsigned int line,
uintptr_t pReserved)
{
wprintf(L"Invalid parameter detected in function %s."
L" File: %s Line: %d\n", function, file, line);
wprintf(L"Expression: %s\n", expression);
}
void main()
{
struct tm when;
int yy=00, mm=00,dd=00;
char date[20];
errno_t errNo;
strcpy(date,"2010-05-03");
sscanf_s(date,"%4d-%2d-%2d",&yy,&mm,&dd);
printf("year : %4d\n",yy);
printf("month : %2d\n",mm);
printf("date : %2d\n",dd);
when.tm_year = yy - 1900;
when.tm_mon = mm - 1;
when.tm_mday = dd;
when.tm_hour = 0;
when.tm_min = 0;
when.tm_sec = 0;
when.tm_wday = 0;
_invalid_parameter_handler oldHandler, newHandler;
newHandler = myInvalidParameterHandler;
oldHandler = _set_invalid_parameter_handler(newHandler);
_CrtSetReportMode(_CRT_ASSERT , 0);
errNo = asctime_s(date,32,&when);
printf("date is right...\n");
}
它给出正确的输出,但是当应用程序终止时,错误是"Run-Time Check Failure #2 - Stack around the variable ''dd'' was corrupted. "
....什么是解决方案?
It gives the proper output but when the application terminates , error is "Run-Time Check Failure #2 - Stack around the variable ''dd'' was corrupted. "
.... what is solution??
推荐答案
这篇关于变量周围的堆栈已损坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!