发生异常错误Stack around the variable 'XXX' was corrupted
vs2019下,程序结果能出来,但是出现Run-Time Check Failure #2 - Stack around the variable ‘XXX’ was corrupted.
原因:
Stack pointer corruption is caused writing outside the allocated buffer in stack memory.
解决方案:
在项目属性下-》C/C++下的-》代码生成-》基本运行时检查
有一下几个选项:
(1) 默认值
(2) 堆栈帧 ( /RTCs )
(3) 未初始化的变量 ( /RTCsu )
(4) 两者 ( /RTC1, 等同与 /RTCsu )
(5) <从父级或项目默认设置继承>
选择默认就合适了。
这里是引用