作者Ctmate (City*Mate)
看板C_and_CPP
标题Re: [问题] 二阶指标的动态记忆体
时间Sun Oct 18 11:46:11 2009
嗯嗯 我已经弄好了
那另外请教
如果
int **buf1_num;
int **buf1_cof;
fp = fopen("input.txt", "r");
fscanf (fp, "%d" ,&k);
buf1_num=(int**)malloc( 2*k );
buf1_cof=(int**)malloc( 2*k );
for (i=0;i<2*k;i++)
{
y=0;
fscanf(fp, "%d %d",&a,&b);
while (a!=0 || b!=0)
{
y++;
buf1_num[i]=(int*)malloc(2*sizeof y+1);
buf1_cof[i]=(int*)malloc(2*sizeof y+1);
fscanf(fp, "%d %d\n",&a,&b);
}
我想要把buf1_num buf1_cof 全部清空都变为零要怎麽弄
一定要用loop吗?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.113.249.122
1F:推 snowlike:calloc or memset 10/18 12:05
2F:→ snowlike:malloc(单位byte)1个int占几byte?通常用sizeof确定型态 10/18 12:05
3F:→ snowlike:while里面重复malloc没有free 10/18 12:06