初学者!C小程序转Delphi程序,谢!(100分)(100分)

  • 主题发起人 主题发起人 zhengv
  • 开始时间 开始时间
Z

zhengv

Unregistered / Unconfirmed
GUEST, unregistred user!
#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(&amp;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;

}
 
晕倒,太小儿科了吧,你是不懂C还是不懂pascal还是两样都不懂呵。
fopen = reset
fclose = close
fread = read
fwrite = write
pascal对文本文件而言,格式化是自动执行的
 
大侠!您说对了,我是不懂,所以想把这个C程序翻译成Delphi程序用以学习,这个程序有
记录文件打开显示等我想学的内容,请您译详细些好吗?
 
main那段这样来:
f: FILE of byte;

assign(f, '01.day');
reset(f);
if IOResult <> 0 then

begin
writeln('Error: Can''t open 01.DAY !');
end;
else
begin

readrec(f);

close(f);

while not keypresseddo
;
end;

不过这可不是delphi呵,这是pascal
 
谢谢你的帮助!
 
后退
顶部