主题:谭浩强 10.4题目,我为啥运行编译没错,运行就不灵了
编程软件 VC2013
#include "stdafx.h"
#include<stdlib.h>
#include <string.h>
#include <stdio.h>
int main(void)
{void change(int pp[], int x, int y);
int number[20], n, m,i;
printf("how many number you input \n");
scanf_s("%d", &n);
printf("change act :\n");
scanf_s("%d", &m);
printf("please input you number :: \n");
for (i = 0; i < n; i++)
{
scanf_s("%d", &number[i]);
}
printf("you input array number is : \n");
for (i = 0; i < n; i++)
{
printf("%d ",number[i]);
}
printf(" i want to change the order of number :\n");
change(number, n, m); //调用更改函数
for (i = 0; i < n; i++)
{
printf("%d ", number[i]);
}
system("pause");
return 0;
}
void change(int array[20], int x, int y)
{
int *p, array_end;
array_end = *(array + x - 1);
for (p = (array + x - 1); p > array; p--)
{
*p = *(p - 1);
}
*array = array_end;
if (y > 0) change(array, x, y);
}
编译信息:
1>------ 已启动全部重新生成: 项目: test_c, 配置: Debug Win32 ------
1> stdafx.cpp
1> test_c.cpp
1> test_c.vcxproj -> D:\VC程序\test_c\Debug\test_c.exe
========== 全部重新生成: 成功 1 个,失败 0 个,跳过 0 个 ==========
运行就出现:
0x013413D9 处有未经处理的异常(在 test_c.exe 中): 0xC00000FD: Stack overflow (参数: 0x00000001, 0x01012FC8)。
这咋回事?
谢谢各位大神!