求大神看一下这个问题在哪,调试半天都不行
#include<iostream>#include<string>
#include<math.h>
#include <stdlib.h>
using namespace std;
char ch1[10];
int num =1;
char ch3[] = "normal";
char ch4[] = "vertex";
char ch5[] = "endfacet";
struct Normal
{
int ID;
char fx;
char fy;
char fz;
}normal;
struct Vertex
{
double vx;
double vy;
double vz;
}vertex;
FILE *fp;
int judge0()
{
fscanf(fp,"%s",ch1);
if(strcmp(ch1,ch3) == 0)
{
return 1;
}
else if(strcmp(ch1,ch4) == 0)
{
return 2;
}
else if(strcmp(ch1,ch5) == 0)
{
return 3;
}
else
{
return 4;
}
}
void judge1()
{
switch(judge0())
{
case 1:
normal.ID = num;
fscanf(fp,"%e",normal.fx);
fscanf(fp,"%e",normal.fy);
fscanf(fp,"%e",normal.fz);
printf("%e %e %e\n",normal.fx,normal.fy,normal.fz);
printf("%d\n",normal.ID);
break;
case 2:
fscanf(fp,"%e",vertex.vx);
fscanf(fp,"%e",vertex.vy);
fscanf(fp,"%e",vertex.vz);
printf("%e %e %e\n",vertex.vx,vertex.vy,vertex.vz);
break;
case 3:
num++;
break;
case 4:
break;
}
}
int main()
{
fp = fopen("D:\\111.txt","r");
while (!feof(fp))
{
judge1();
}
//getchar();
fclose(fp);
return 0;
}