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");
}
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??