首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

高手帮忙,多谢

2012-03-09 
高手帮忙,谢谢#includestdafx.h #include stdio.h #includestring.h structbank{intidcharname[30]

高手帮忙,谢谢
#include   "stdafx.h "
#include "stdio.h "
#include   "string.h "
struct   bank
{
int   id;
char   name[30];
float   money;
};
  void   wirtexinxi(FILE   *fp)
  {
  struct   bank   sell;
  char   temp[30]={0};
  int   i;
aa:   printf( "输入客户编号(1-100),想结束请输入-1:\n ");
          scanf( "%d ",&i);
  getchar();
  fseek(fp,(i-1)*sizeof(struct   bank),0);
  fread(&sell,sizeof(struct   bank),1,fp);
  if(sell.id!=0)
  {
  printf( "此客户已经存在,请从新输入 ");
  goto   aa;
  }
  while(i!=-1)
  {
sell.id=i;
                printf( "输入客户姓名:\n ");
gets(temp);
strcpy(sell.name,temp);
printf( "输入客户的存款\n ");
scanf( "%f ",sell.money);

fseek(fp,(i-1)*sizeof(struct   bank),0);
fwrite(&sell,sizeof(struct   bank),1,fp);
bb:       printf( "输入客户编号(1-100),想结束请输入-1:\n ");
scanf( "%d ",&i);
getchar();
fseek(fp,(i-1)*sizeof(struct   bank),0);
        fread(&sell,sizeof(struct   bank),1,fp);
if(sell.id!=0)
{
printf( "此用户已经存在,请从新输入:\n ");
goto   bb;
}
scanf( "%d ",&i);
  }
  }

int   main(int   argc,   char*   argv[])
{

FILE   *fp;
if((fp=fopen( "D:\\分配银行系统空间\\Debug\\bank.dat ", "rb+ "))==NULL)
{
printf( "文件打开失败 ");

}

wirtexinxi(fp);

return   0;
}
不明白运行到输入存款后就无法运行了。提示运行错误。怎么该都不行。请那位高手指教一下。谢谢

[解决办法]
scanf函数调用参数用错,只能接收地址
scanf( "%f ",&(sell.money));

热点排行