如何用DELPHI读取文本文件的最后一行

2024-12-17 01:13:01
推荐回答(1个)
回答1:

turbo_pascal代码:
var
f:text;
st:string;
begin
assign(f,'test.txt');
reset(f);
while not eof(f) do readln(f,st);
close(f);
writeln(st);
end.


------------------------
delphi_pascal代码:
program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
f:text;
st:string;
begin
assign(f,'test.txt');
reset(f);
while not eof(f) do readln(f,st);
close(f);
writeln(st);
  readln;
end.