字符串数组 Debug 系统回收空间引起程序崩溃

demo

void testfunc(int iNum)
{
    char sztest[3];
    memset(sztest, 0, 3);
    sprintf(sztest, "%03d", iNum);
    return;
}

控制台程序程序,调试时,当执行到函数结束时,程序会崩溃(不中断,可以继续执行),原因待定。栈(stack)”和“堆(heap),字符数组属于临时变量,声明时会在站上开辟空间。

Stack around the variable 'sztest' was corrupted

posted @ 2019-05-17 23:32  N_zero  阅读(168)  评论(0)    收藏  举报