inquire函数C语言,问一个关于clrsrc函数的问题

#include

#include

#include

struct BUY

{

char sort[10];

char season[10];

char brand[10];

int  q;

char location[20];

};

struct QUERY

{

char sort[10];

char season[10];

};

void purchase(struct BUY buy1);

void query(struct QUERY query1);

main()

{

int option=10;

struct BUY buy1;

struct QUERY query1;

int con=1;

while(con)

{

printf("service type as follows\n");

printf("1:add new purchasing\t 2:inquire about present storage\t 0:exit\n");

scanf("%1d",&option);

clrsrc();——————————————————————在这

switch(option)

{

case 0:

exit(1);

case 1:

printf("input things newly purchased\n");

printf("directions:\n");

printf("input list as follows:clothes summer nike 1 room1\n");

printf("sorted   as: clothes\t shoesandhats \n");

printf("seasoned as: summer\t winter\t others \n");

printf("nike represents the brand; 1 represents quanity \n");

printf("room1cabinet represents the location \n");

scanf("%s %s %s %d %s",buy1.sort,buy1.season,buy1.brand,&buy1.q,buy1.location);

purchase(buy1);

break;

case 2:

printf("input the list for inquiry\n");

printf("inquiry list formation is as follows:");

printf("clothes summer \n");

scanf("%s %s",&query1.sort,&query1.season);

query(query1);

break;

default:

;

}

printf("continue:1 exit:0\n");

scanf("%d",&con);

}

}

void purchase(struct BUY buy1)

{

FILE *fp;

fp=fopen("d:\\purchase.txt","a+");

fprintf(fp,"%s ",buy1.sort);

fprintf(fp,"%s ",buy1.season);

fprintf(fp,"%s ",buy1.brand);

fprintf(fp,"%d ",buy1.q);

fprintf(fp,"%s\n",buy1.location);

fclose(fp);

}

void query(struct QUERY query1)

{

struct QUERY query2;

struct BUY    buy2;

long number;

FILE *fp;

fp=fopen("d:\\purchase.txt","r");

if((fp=fopen("d:\\purchase.txt","r"))==NULL)

{

printf("file do not exist\n");

exit(1);

}

while(getc(fp)!=EOF)

{

fseek(fp,-1L,SEEK_CUR);

number=ftell(fp);

fscanf(fp,"%s %s ",query2.sort,query2.season);

if(!strcmp(query2.sort,query1.sort)&&!strcmp(query2.season,query1.season))

{

fseek(fp,number,SEEK_SET);

fscanf(fp,"%s %s %s %d %s",buy2.sort,buy2.season,buy2.brand,&buy2.q,buy2.location);

fprintf(stdout,"%s %s %s %d %s\n",buy2.sort,buy2.season,buy2.brand,buy2.q,buy2.location);

}

while(getc(fp)!='\n')

{

fseek(fp,1L,SEEK_CUR);

}

}

fclose(fp);

}

[本帖最后由 rainybear 于 2009-11-24 00:24 编辑]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值