| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 535 人关注过本帖
标题:救助!
只看楼主 加入收藏
alpha720
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-3-31
收藏
 问题点数:0 回复次数: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)也不行,究竟如何才能多次构造数据呢,上述只是一个例子,其它方面的也出现类似情况.给些点子过我好吗?谢谢大家!
搜索更多相关主题的帖子: 救助 
2008-06-26 06:38
快速回复:救助!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015898 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved