标题:求大神看一下这个问题在哪,调试半天都不行
只看楼主
ge951037511
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2017-7-17
 问题点数:0 回复次数:0 
求大神看一下这个问题在哪,调试半天都不行
#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;
}
搜索更多相关主题的帖子: char int fscanf return case 
2017-07-27 10:39



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-479644-1-1.html




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

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