我将BufferOut
定义为16个元素数组。
但我在调试时会面对此消息。
Run-Time Check Failure #2 - Stack around the variable 'BufferOut' was corrupted.
HIDBufferOut
是char
数组
HIDBufferOut BufferOut; // first element is the report ID
BufferOut[0] = 0;
BufferOut[1] = 211;
BufferOut[16] = 44;
BufferOut[4] = 4;
.
.
.
.
etc
答案 0 :(得分:2)
如果BufferOut
是16个元素缓冲区,则有效索引为0,...,15。这意味着:
BufferOut[16] = (int) 44;
写出超出数组的范围,导致内存损坏。
答案 1 :(得分:0)
这通常发生在您无法触及的位置上,导致缓冲区溢出,并且从这段代码中清除堆栈损坏: BufferOut [16] =(int)44; //你在第17个地方写出界外
答案 2 :(得分:-1)