BUG:Run-Time Check Failure #2 - Stack around the variable 'a' was corrupted.
Why?
#include <iostream>
int main()
{
char a[] = "hello";
a[6] = 'A';
std::cout << a;
system("pause");
return 0;
}
问题处在代码的下一行。数组a,在STACK上内存分配成功,但是操作超过了内存的边界,所以导致STACK corrupted
a[6] = 'A';
如果把a[6]修改为a[0],问题就可以解决了。