| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 426 人关注过本帖
标题:[讨论],怎么建立文件啊,用tc!
取消只看楼主 加入收藏
wsjmt2334031
Rank: 1
等 级:新手上路
帖 子:35
专家分:0
注 册:2004-11-17
收藏
 问题点数:0 回复次数:0 
[讨论],怎么建立文件啊,用tc!

为什么打 不开文件啊,我在D:盘建了文件了啊,怎么打不开啊,用记事本建的,哪位高人指点啊??????不胜感激啊!!!!!!

如何建立文件,用tc,指教!1
#include"stdio.h"
void OpenFile(void);
void PrnHeadings(void);
void ProcessLoop(void);
void ReadRecord(void);
float CalcTotal(void);
float CalcAvr(float);
void PrnDetail(float);
char PT1[]=" S I X-W E E K S G R A D E R E P O R T ";
char HL1[]="student text Score Average";
char HL2[]="-----------------------------------------------";
FILE *fpGrade;
char sStudent[16];
int iGrade1;
int iGrade2;
int iGrade3;
int iGrade4;
int iGrade5;
int iGrade6;
main()
{
OpenFile();
if(fpGrade!=0)
{
PrnHeadings();
ProcessLoop();
fclose(fpGrade);
}
return;
}
void OpenFile(void)
{
fpGrade=fopen("d:txGrades.txt","r");
if(fpGrade==0)
{
printf("\nCannot open grades file for input\n");
}
return;
}
void PrnHeadings(void)
{
printf(PT1);
printf("\n\n\n");
printf(HL1);
printf("\n");
printf(HL2);
printf("\n");
return;
}
void ProcessLoop(void)
{
float fGradeTot;
float fGradeAvr;
ReadRecord();
while(!feof(fpGrade))
{
fGradeTot=CalcTotal();
fGradeAvr=CalcAvr(fGradeTot);
PrnDetail(fGradeAvr);
ReadRecord();
}
return;
}
void ReadRecord(void)
{
fscanf(fpGrade,"%15[^\n] %d %d %d %d %d %d",sStudent,&iGrade1,&iGrade2,&iGrade3,&iGrade4,&iGrade5,&iGrade6);
return;
}
float CalcTotal(void)
{
float fGradeTot;
fGradeTot=iGrade1+iGrade2+iGrade3+iGrade4+iGrade5+iGrade6;
return fGradeTot;
}
float CalcAvr(float fGradeTot)
{
float fGradeAvr;
fGradeAvr=fGradeTot/6;
return fGradeAvr;
}
void PrnDetail(float fGradeAvr)
{
printf("\n %-15s %3d %3d %3d %3d %3d %3d %6.2f",sStudent,iGrade1,
iGrade2,iGrade3,iGrade4,iGrade5,iGrade6,fGradeAvr);
return;
}


搜索更多相关主题的帖子: void float 文件 
2006-04-11 14:12
快速回复:[讨论],怎么建立文件啊,用tc!
数据加载中...
 
   



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

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