include <stdio.h>
int main()
{
char a[] = { "zxcvbnmasdfk" };
char b[] = { "############" };
int L = 0;
int R = 11;
while (L <= (R+2))
{
printf("%s\n", b);
b[L] = a[L];
b[R] = a[R];
L++;
R--;
}
return 0;
}
运行程序遇到这样的错误:Run-Time Check Failure #2 - Stack around the variable 'b' was corrupted.
检查后发现原因在于:数组b越界了,int b[4]里面有4个元素,包含b[0],b[1],b[2],b[3],没有b[4],赋值的时候把某个数据赋给了b[4]