标题:各位大虾们帮我看看问题在哪里?满头大汗的等待ing!
只看楼主
hjmHhyp
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2008-10-9
 问题点数:0 回复次数:1 
各位大虾们帮我看看问题在哪里?满头大汗的等待ing!
#include <stdio.h>
#include "head.h"

main()
{
    struct student s[5];
    int i;
    FILE *fp1,*fp2;
    fp1=fopen("zhang.txt","r");
    fp2=fopen("ju.txt","w");
    for(i=0;i<=4;i++)
    {
        fscanf(fp1,"%s",s[i].name);
        fscanf(fp1,"%d",&s[i].id);
        fscanf(fp1,"%lf",&s[i].politics);
        fscanf(fp1,"%lf",&s[i].english);
        fscanf(fp1,"%lf",&s[i].math);
        fscanf(fp1,"%lf",&s[i].special);
        s[i].cheng_ji=s[i].english+s[i].math+s[i].politics+s[i].special;
    }
    fprintf(fp2,"name\t\tid\tpol\teng\tmat\tspe\tche\n");
    for(i=0;i<=4;i++)
    {
        fprintf(fp2,"%s\t",s[i].name);
        fprintf(fp2,"%d\t",s[i].id;
        fprintf(fp2,"%g\t",s[i].politics);
        fprintf(fp2,"%g\t",s[i].english);
        fprintf(fp2,"%g\t",s[i].math);
        fprintf(fp2,"%g\t",s[i].special);
        fprintf(fp2,"%g\t",s[i].cheng_ji);
    }

}
另外head.h的头文件如下:struct student
{
    char name[30];
    int id;
    double politics;
    double english;
    double math;
    double special;
    double cheng_ji;
}

编译和运行均出现如下提示:f:\c 语言程序\two\main.c(4) : error C2059: syntax error : 'PCH creation point',希望高手给予解答。zhang.txt文件已建,名称为zhang。
搜索更多相关主题的帖子: ing 
2008-11-19 21:24
hjmHhyp
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2008-10-9
得分:0 
发现了,原始是个语法错误,我将发现错误的方法告诉大家,希望对需要的人有所帮助。我先把head.h的内容放在#include“head.h”的下一行,再封了#include“head.h”,然后编译就能轻而易举的发现错误。利用的是预编译的原理。

错误行:fprintf(fp2,"%d\t",s[i].id;(第二个for语句中)
收到的鲜花
  • 永夜的极光2008-11-19 21:47 送鲜花  49朵   附言:谢谢分享经验
2008-11-19 21:37



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




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

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