Run-Time Check Failure #2 - Stack around the variable 'e' was corrupted.我是用的C语言,我的源代码如下:#includeint main(){\x05short/*short如改成int就不会stack was corrupted了*/ a=0,b=0,c=0,d=0,e=0;\x05puts("Input a number that end
来源:学生作业帮助网 编辑:作业帮 时间:2024/07/17 20:29:52
![Run-Time Check Failure #2 - Stack around the variable 'e' was corrupted.我是用的C语言,我的源代码如下:#includeint main(){\x05short/*short如改成int就不会stack was corrupted了*/ a=0,b=0,c=0,d=0,e=0;\x05puts(](/uploads/image/z/9693126-54-6.jpg?t=Run-Time+Check+Failure+%232+-+Stack+around+the+variable+%27e%27+was+corrupted.%E6%88%91%E6%98%AF%E7%94%A8%E7%9A%84C%E8%AF%AD%E8%A8%80%2C%E6%88%91%E7%9A%84%E6%BA%90%E4%BB%A3%E7%A0%81%E5%A6%82%E4%B8%8B%EF%BC%9A%23includeint+main%28%29%7B%5Cx05short%2F%2Ashort%E5%A6%82%E6%94%B9%E6%88%90int%E5%B0%B1%E4%B8%8D%E4%BC%9Astack+was+corrupted%E4%BA%86%2A%2F+a%3D0%2Cb%3D0%2Cc%3D0%2Cd%3D0%2Ce%3D0%3B%5Cx05puts%28%22Input+a+number+that+end)
Run-Time Check Failure #2 - Stack around the variable 'e' was corrupted.我是用的C语言,我的源代码如下:#includeint main(){\x05short/*short如改成int就不会stack was corrupted了*/ a=0,b=0,c=0,d=0,e=0;\x05puts("Input a number that end
Run-Time Check Failure #2 - Stack around the variable 'e' was corrupted.
我是用的C语言,我的源代码如下:
#include
int main()
{
\x05short/*short如改成int就不会stack was corrupted了*/ a=0,b=0,c=0,d=0,e=0;
\x05puts("Input a number that ends with a '.'");
\x05scanf("%1d%1d%1d%1d%1d",&a,&b,&c,&d,&e);
\x05if(e)
\x05{
\x05\x05puts("five digits");
\x05\x05printf("%d %d %d %d %d\n",a,b,c,d,e);
\x05\x05printf("%d%d%d%d%d\n",e,d,c,b,a);
\x05}
\x05else if(d)
\x05{
\x05\x05puts("four digits");
\x05\x05printf("%d %d %d %d\n",a,b,c,d);
\x05\x05printf("%d%d%d%d\n",d,c,b,a);
\x05}
\x05else if(c)
\x05{
\x05\x05puts("three digits");
\x05\x05printf("%d %d %d\n",a,b,c);
\x05\x05printf("%d%d%d\n",c,b,a);
\x05}
\x05else if(b)
\x05{
\x05\x05puts("two digits");
\x05\x05printf("%d %d\n",a,b);
\x05\x05printf("%d%d\n",b,a);
\x05}
\x05else if(a)
\x05{
\x05\x05puts("one digit");
\x05\x05printf("%d\n",a);
\x05\x05printf("%d\n",a);
\x05}
\x05else
\x05{
\x05\x05puts("the number is zero");
\x05\x05printf("0\n");
\x05\x05printf("0\n");
\x05}
\x05return 0;
}
结果出现了题目中的错误提示,如果short改成int,则一切正常,
Run-Time Check Failure #2 - Stack around the variable 'e' was corrupted.我是用的C语言,我的源代码如下:#includeint main(){\x05short/*short如改成int就不会stack was corrupted了*/ a=0,b=0,c=0,d=0,e=0;\x05puts("Input a number that end
scanf( "%d",...) 需要你传一个int大小的地址
short 是2字节,int是4字节,你给需要4字节的,传一个2字节,自然就溢出了,好比,1L的瓶子,你灌了2L的水,是不是就溢出了?