堆的释放问题
#include<stdio.h>#include<conio.h>
#include<stdlib.h>
double mi(int n,double j)/*进行幂运算*/
{
double sum=1;
if(n==0&&j!=0)
return(1);
if(j==0)return(0);
for(int i=1;i<=n;i++)sum=sum*j;
return(sum);
}
void main()
{
int n,*p,i=0;
double sum=0,highta,hight,hightb,wise=0,a,b;
printf("*******************************\n");
printf(" 数学多项式积分器 \n ");
printf(" 欢迎使用\n");
printf("*******************************\n");
printf("按任意键开始\n");
while(getch()!='q')
{
sum=0;
printf("输入最大阶数:");
scanf("%d",&n);
p=(int *)malloc(sizeof(int)*n);
for(i=0;i<=n;i++)
{
printf("输入第%d阶的系数\n",i);
scanf("%d",p+i);
}
for(wise=0;wise<10;wise=wise+0.0001)
{
highta=0;
hightb=0;
for(i=0;i<=n;i++)
{
a=mi(i,wise);
b=mi(i,wise+0.0001);
highta=highta+p[i]*a;
hightb=hightb+p[i]*b;
}
hight=(highta+hightb)/2;
sum=sum+0.0001*hight;
}
printf("%f\n",sum);
printf("按任意键开始,按q停止\n");
}
}
在不释放堆的情况下,程序能正常运行,但一释放堆的数据就出现警告,我想知道这是为什么,不是说堆的分配和释放都由程序员操作吗?请各位高人指教