当前位置: 代码迷 >> C语言 >> 救助!
  详细解决方案

救助!

热度:566   发布时间:2008-06-26 06:38:58.0
救助!
先看下面程序
#include "malloc.h"
#include "Stdio.h"
#include "Conio.h"
typedef float ElemType;
typedef struct FuSu
{
ElemType a;
ElemType b;
}FuSu,*FuSu1;
void CreatFuSu ()
{    float i,j,k,l;
         FuSu1 f1,f2;
      f1=(FuSu1)malloc(sizeof( FuSu));
   f2=(FuSu1)malloc(sizeof( FuSu));
  printf("please insert the num below:\n");
   scanf("%f,%f;%f,%f",&i,&j,&k,&l );
    f1->a=i;
     f1->b=j;
      f2->a=k;
       f2->b=l;
       if(j==0&&l==0) printf("the two FuSu are :%f,%f \n",f1->a , f2->a);
       if(j==0&&l!=0&&l>0)printf("the two FuSu are :%f;%f+i%f\n",f1->a,f2->a,f2->b );
       if(j==0&&l!=0&&l<0) printf("the two FuSu are :%f;%f-i%f\n",f1->a,f2->a,(-(f2->b)) );
       if(j!=0&& l==0&&j>0) printf("the two FuSu are :%f+i%f;%f\n",f1->a,f1->b,f2->a );
       if(j!=0&& l==0&&j<0) printf("the two FuSu are :%f-i%f;%f\n",f1->a,(-(f1->b)),f2->a );
        if(j!=0&&l!=0&&j>0&l>0) printf("the two FuSu are :%f+i%f;%f+i%f\n",f1->a,f1->b,f2->a,f2->b );
        if(j!=0&&l!=0&&j<0&l>0) printf("the two FuSu are :%f-i%f;%f+i%f\n",f1->a,(-(f1->b)),f2->a,f2->b );
        if(j!=0&&l!=0&&j>0&l<0) printf("the two FuSu are :%f+i%f;%f-i%f\n",f1->a,f1->b,f2->a,(-(f2->b))  );
        if(j!=0&&l!=0&&j<0&l<0) printf("the two FuSu are :%f-i%f;%f-i%f\n",f1->a,(-(f1->b)),f2->a,(-(f2->b)) );

     }


int main(void)
{
CreatFuSu ();
     getch();
      CreatFuSu ();
  getch();
  return 0;
}

我的问题是:2次以上调用构造函数CreatFuSu ()就不行了,即使我在CreatFuSu ()内加free(f1)和free(f2)也不行,究竟如何才能多次构造数据呢,上述只是一个例子,其它方面的也出现类似情况.给些点子过我好吗?谢谢大家!
搜索更多相关的解决方案: 救助  

----------------解决方案--------------------------------------------------------
  相关解决方案