S
sosme
Unregistered / Unconfirmed
GUEST, unregistred user!
大侠!您说对了,我是不懂,所以想把这个C程序翻译成Delphi程序用以学习,这个程序有
记录文件打开显示等我想学的内容,请您译详细些好吗?
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
typedef struct {
unsigned long date;
unsigned long open;
unsigned long high;
unsigned long low;
unsigned long close;
unsigned long travl;
unsigned long traca;
char unuse[12];
} RECORD;
RECORD reco;
int readrec(FILE *);
void main()
{
FILE *fp;
if((fp = fopen("01.day","rb")) == NULL)
{ printf("Error: Can't open 01.DAY !/n");
exit(0);
}
readrec(fp);
fclose(fp);
if(getch()==0) getch();
exit(0);
}
int readrec(FILE *fp)
{
float fn;
while (! feof(fp)) {
fread(&reco,sizeof(RECORD),1,fp);
printf("%10lu ",reco.date);
fn=float(reco.open)/1000;
printf("%8.2f ",fn);
fn=float(reco.high)/1000;
printf("%8.2f ",fn);
fn=float(reco.low)/1000;
printf("%8.2f ",fn);
fn=float(reco.close)/1000;
printf("%8.2f ",fn);
printf("%8lu ",reco.travl);
printf("%8lu/n",reco.traca);
}
printf("/n");
return 0;
}
记录文件打开显示等我想学的内容,请您译详细些好吗?
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
typedef struct {
unsigned long date;
unsigned long open;
unsigned long high;
unsigned long low;
unsigned long close;
unsigned long travl;
unsigned long traca;
char unuse[12];
} RECORD;
RECORD reco;
int readrec(FILE *);
void main()
{
FILE *fp;
if((fp = fopen("01.day","rb")) == NULL)
{ printf("Error: Can't open 01.DAY !/n");
exit(0);
}
readrec(fp);
fclose(fp);
if(getch()==0) getch();
exit(0);
}
int readrec(FILE *fp)
{
float fn;
while (! feof(fp)) {
fread(&reco,sizeof(RECORD),1,fp);
printf("%10lu ",reco.date);
fn=float(reco.open)/1000;
printf("%8.2f ",fn);
fn=float(reco.high)/1000;
printf("%8.2f ",fn);
fn=float(reco.low)/1000;
printf("%8.2f ",fn);
fn=float(reco.close)/1000;
printf("%8.2f ",fn);
printf("%8lu ",reco.travl);
printf("%8lu/n",reco.traca);
}
printf("/n");
return 0;
}