| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2097 人关注过本帖
标题:问一个关于clrsrc函数的问题
只看楼主 加入收藏
rainybear
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2007-4-20
收藏
 问题点数:0 回复次数:8 
问一个关于clrsrc函数的问题
就是打算用它清除已经输出打印的东西
加了头文件conio.h
但还是编译过 运行报错

求达人指点
搜索更多相关主题的帖子: 函数 clrsrc 
2009-11-24 00:11
xy4919961
Rank: 5Rank: 5
等 级:职业侠客
帖 子:199
专家分:362
注 册:2009-10-24
收藏
得分:0 
clrsrc 这是清屏函数..
 没头文件一样可以用..
应该是你代码写错..你发你的原码

QQ群:96348241
2009-11-24 00:15
rainybear
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2007-4-20
收藏
得分:0 
回复 2楼 xy4919961
问题 没加这个函数的时候 程序跑起来是正常的啊
2009-11-24 00:18
rainybear
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2007-4-20
收藏
得分:0 
#include <stdio.h>
#include <string.h>
#include <conio.h>
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 编辑 ]
2009-11-24 00:19
xy4919961
Rank: 5Rank: 5
等 级:职业侠客
帖 子:199
专家分:362
注 册:2009-10-24
收藏
得分:0 
#include <stdio.h>
#include <string.h>
#include <conio.h>
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);
clrscr();
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);
}
            你把函数写错了。.

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

QQ群:96348241
2009-11-24 00:36
rainybear
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2007-4-20
收藏
得分:0 
回复 5楼 xy4919961
呃 这么弱智的错误
啊………
2009-11-24 00:40
xy4919961
Rank: 5Rank: 5
等 级:职业侠客
帖 子:199
专家分:362
注 册:2009-10-24
收藏
得分:0 
回复 6楼 rainybear
.

QQ群:96348241
2009-11-24 00:51
仰望者
Rank: 2
等 级:论坛游民
帖 子:57
专家分:86
注 册:2009-11-6
收藏
得分:0 
LZ呵呵1
2009-11-24 11:12
caojulians
Rank: 2
等 级:论坛游民
帖 子:39
专家分:67
注 册:2009-11-15
收藏
得分:0 
回复 8楼 仰望者
这个函数不是ANSI C中的标准函数,只是TC和BC系统中自己扩展的函数,没有可移植性----不要在这儿下功夫!
2009-11-24 12:43
快速回复:问一个关于clrsrc函数的问题
数据加载中...
 
   



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

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