| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1314 人关注过本帖
标题:谁能帮我看看这段代码哪里出错了,运行不了
只看楼主 加入收藏
youxin123
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2016-5-9
结帖率:0
收藏
已结贴  问题点数:20 回复次数:3 
谁能帮我看看这段代码哪里出错了,运行不了
#include"stdio.h"
#include"math.h"
        FILE*fp;
        int i,gcode;
        char fname[14],gvalue[65];
        float xs[100],ys[100],zs[100],xe[100],ye[100],ze[100];
        main()
        {int n;
        i=0;
        scanline();
        printf("Enter data file name:");
        scanf("%s",fname);
        fp=fopen(fname,"w");
        fprintf(fp,"%d\n",i);
        for(n=1;n<=i;n++)
        {fprintf(fp,"%f,%f,%f\n",xs[n],ys[n],zs[n]);
        fprintf(fp,"%f,%f,%f\n",xe[n],ye[n],ze[n]);
        }
        fclose(fp);
        }
        int scanline()
        {printf("Enter DXF file name:");
        scanf("%s",fname);
        strcat(fname,".dxf");
        fp=fopen(fname,"r");
        do{fscanf(fp,"%d",&gcode);
        fscanf(fp,"%s",gvalue);
        }while(gcode!=2||strcmp(gvalue,"ENTITIES")!=0);
        do{fscanf(fp,"%d",&gcode);
        fscanf(fp,"%s",gvalue);
        if(gcode==0&&strcmp(gvalue,"LINE")==0)outline();
        }while(gcode!=0||strcmp(gvalue,"ENDSEC")!=0);
        fclose(fp);
        return0;
        }
        int outline()
        {do{fscanf(fp,"%d",&gcode);
        if(gcode==10)
        {i=i+1;
        fscanf(fp,"%f",&xs[i]);
        }
        else
        fscanf(fp,"%s",gvalue);
        }while(gcode!=10);
        fscanf(fp,"%d",&gcode);
        fscanf(fp,"%f",&ys[i]);
        fscanf(fp,"%d",&gcode);
        fscanf(fp,"%f",&zs[i]);
        fscanf(fp,"%d",&gcode);
        fscanf(fp,"%f",&xe[i]);
        fscanf(fp,"%d",&gcode);
        fscanf(fp,"%f",&ye[i]);
        fscanf(fp,"%d",&gcode);
        fscanf(fp,"%f",&ze[i]);
        return0;
        }
搜索更多相关主题的帖子: include Enter file 
2016-05-09 15:55
zhulei1978
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:53
帖 子:1351
专家分:1200
注 册:2006-12-17
收藏
得分:10 
#include"stdio.h"
 #include"math.h"
         FILE*fp;
         int i,gcode;
         char fname[14],gvalue[65];
         float xs[100],ys[100],zs[100],xe[100],ye[100],ze[100];
         main()
         {int n;
         i=0;
         scanline();
         printf("Enter data file name:");
         scanf("%s",fname);
         fp=fopen(fname,"w");
         fprintf(fp,"%d\n",i);
         for(n=1;n<=i;n++)
         {fprintf(fp,"%f,%f,%f\n",xs[n],ys[n],zs[n]);
         fprintf(fp,"%f,%f,%f\n",xe[n],ye[n],ze[n]);
         }
         fclose(fp);
         }
         int scanline()
         {printf("Enter DXF file name:");
         scanf("%s",fname);
         strcat(fname,".dxf");
         fp=fopen(fname,"r");
         do{fscanf(fp,"%d",&gcode);
         fscanf(fp,"%s",gvalue);
         }while(gcode!=2||strcmp(gvalue,"ENTITIES")!=0);
         do{fscanf(fp,"%d",&gcode);
         fscanf(fp,"%s",gvalue);
         if(gcode==0&&strcmp(gvalue,"LINE")==0)outline();
         }while(gcode!=0||strcmp(gvalue,"ENDSEC")!=0);
         fclose(fp);
         return 0;
         }
         int outline()
         {do{fscanf(fp,"%d",&gcode);
         if(gcode==10)
         {i=i+1;
         fscanf(fp,"%f",&xs[i]);
         }
         else
         fscanf(fp,"%s",gvalue);
         }while(gcode!=10);
         fscanf(fp,"%d",&gcode);
         fscanf(fp,"%f",&ys[i]);
         fscanf(fp,"%d",&gcode);
         fscanf(fp,"%f",&zs[i]);
         fscanf(fp,"%d",&gcode);
         fscanf(fp,"%f",&xe[i]);
         fscanf(fp,"%d",&gcode);
         fscanf(fp,"%f",&ye[i]);
         fscanf(fp,"%d",&gcode);
         fscanf(fp,"%f",&ze[i]);
         return 0;
         }

其实我就是改变社会风气,提高少女素质,刺激电影市道,提高年轻人内涵,玉树临风,风度翩翩的整蛊专家,我名叫古晶,英文名叫JingKoo!
2016-05-09 16:18
吹水佬
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:451
帖 子:10607
专家分:43186
注 册:2014-5-20
收藏
得分:10 
程序代码:
#include"stdio.h"
#include"math.h"
#include"string.h" //问题1 
FILE*fp;
int i,gcode;
char fname[14],gvalue[65];
float xs[100],ys[100],zs[100],xe[100],ye[100],ze[100];
int scanline(); //问题2 
int outline();  //问题3 
main()
{
    int n;
    i=0;
    scanline();
    printf("Enter data file name:");
    scanf("%s",fname);
    fp=fopen(fname,"w");
    fprintf(fp,"%d\n",i);
    for(n=1; n<=i; n++)
    {
        fprintf(fp,"%f,%f,%f\n",xs[n],ys[n],zs[n]);
        fprintf(fp,"%f,%f,%f\n",xe[n],ye[n],ze[n]);
    }
    fclose(fp);
}

int scanline()
{
    printf("Enter DXF file name:");
    scanf("%s",fname);
    strcat(fname,".dxf");
    fp=fopen(fname,"r");
    do
    {
        fscanf(fp,"%d",&gcode);
        fscanf(fp,"%s",gvalue);
    }
    while(gcode!=2||strcmp(gvalue,"ENTITIES")!=0);
    do
    {
        fscanf(fp,"%d",&gcode);
        fscanf(fp,"%s",gvalue);
        if(gcode==0&&strcmp(gvalue,"LINE")==0) outline();
    }
    while(gcode!=0||strcmp(gvalue,"ENDSEC")!=0);
    fclose(fp);
    return 0;   //问题5 
}

int outline()
{
    do
    {
        fscanf(fp,"%d",&gcode);
        if(gcode==10)
        {
            i=i+1;
            fscanf(fp,"%f",&xs[i]);
        }
        else
            fscanf(fp,"%s",gvalue);
    }
    while(gcode!=10);
    fscanf(fp,"%d",&gcode);
    fscanf(fp,"%f",&ys[i]);
    fscanf(fp,"%d",&gcode);
    fscanf(fp,"%f",&zs[i]);
    fscanf(fp,"%d",&gcode);
    fscanf(fp,"%f",&xe[i]);
    fscanf(fp,"%d",&gcode);
    fscanf(fp,"%f",&ye[i]);
    fscanf(fp,"%d",&gcode);
    fscanf(fp,"%f",&ze[i]);
    return 0;   //问题4 
}

2016-05-09 16:36
youxin123
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2016-5-9
收藏
得分:0 
回复 3楼 吹水佬
谢谢
2016-05-09 19:24
快速回复:谁能帮我看看这段代码哪里出错了,运行不了
数据加载中...
 
   



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

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