谁能帮我看一下这段代码哪出问题了,为什么运行不了
#include"stdio.h"#include"math.h"
FILE*fp;
int i,gcode;
char fname,gvalue;
float xs,ys,zs,xe,ye,ze;
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,ys,zs);
fprintf(fp,"%f,%f,%f\n",xe,ye,ze);
}
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);
}
else
fscanf(fp,"%s",gvalue);
}while(gcode!=10);
fscanf(fp,"%d",&gcode);
fscanf(fp,"%f",&ys);
fscanf(fp,"%d",&gcode);
fscanf(fp,"%f",&zs);
fscanf(fp,"%d",&gcode);
fscanf(fp,"%f",&xe);
fscanf(fp,"%d",&gcode);
fscanf(fp,"%f",&ye);
fscanf(fp,"%d",&gcode);
fscanf(fp,"%f",&ze);
return0;
}
页:
[1]