delphi如何实现像C++的fgets功能来读取一行的函数?

delphi如何实现像C++的fgets 读取一行功能的函数?
2024-11-24 02:14:31
推荐回答(1个)
回答1:

当然有,ReadLn就是。例子如下:
var

F: TextFile;
S: string;
begin
if OpenDialog1.Execute then { Display Open dialog box }
begin
AssignFile(F, OpenDialog1.FileName); { File selected in dialog }
Reset(F);
Readln(F, S); { Read first line of file }
Edit1.Text := S; { Put string in a TEdit control }
CloseFile(F);
end;
end;