学生记录要求有:名字,学号。(就两项)
我想请教各位的是:假定学生信息在student.txt中,如何编写程序,读文件中的信息并把它输出???谢谢大家。在线等待。!!!!!!
我想请教各位的是:假定学生信息在student.txt中,如何编写程序,读文件中的信息并把它输出???谢谢大家。在线等待。!!!!!!
解决方案 »
- 我用IdTCPServer和IdTCpclient通讯的时候提示:Missing data provider or data packet
- delphi中怎么获取机器上安装的所有浏览器路径?
- 关于DELPHI指针之间赋值的问题.
- 请教一个关于注册表的问题
- 请教学习~!有关像网络收藏家、网文快捕之类收藏网页的软件将保页等信息保存在一个文件里的相关技术~!
- 一個關於 DBChart 打印的問題... 在線..
- 我用ADO+access执行update或insert的时候,总是报错请问何故?
- 新年马上到了,不知道大家去年过的好吗?大家都进来聊聊。
- 请教有关ADO的问题
- 关于表单的难题,各位大侠请帮帮忙!
- string类型转换成pchar类型时出错
- string类型转换成pchar类型时出错
TStudent=record
id: string[16]; //学号
name: string[32]; //名字
end;
TStudents=record
count: integer;
recs : array of TStudent;
end;//读取记录,同时记录存放在 students 中。
function GetStudentsFromFile(fileName: string; var students: TStudents): boolean;
var
lpFile : file of TStudent;
student: TStudent;
begin
result := false;
if not FileExists(fileName) then
begin
ShowMessage('学生记录文件未找到!');
exit;
end;
try
AssignFile(lpFile,fileName);
reset(lpFile);
students.count := 0;
while not Eof(lpFile) do
begin
read(lpFile,student);
Inc(students.count);
SetLength(students.recs,students.count);
students.recs[students.count-1] := student;
end;
CloseFile(lpFile);
result := true;
except
ShowMessage('系统异常,无效文件或文件读写错误!');
end;
end;
var
thefile:textfile;
filename,s_name,s_num:string;assignfile(thefile,filename);
reset(thefile);
readln(thefile,s_name);
readln(thefile,s_num);
closefile(thefile);
TStudent=record
id: string[16]; //学号
name: string[32]; //名字
end;
TStudents=record
count: integer;
recs : array of TStudent;
end; //读取记录,同时记录存放在 students 中。
function GetStudentsFromFile(fileName: string; var students: TStudents): boolean;
var
lpFile : file of TStudent;
student: TStudent;
begin
result := false;
if not FileExists(fileName) then
begin
ShowMessage( '学生记录文件未找到! ');
exit;
end;
try
AssignFile(lpFile,fileName);
reset(lpFile);
students.count := 0;
while not Eof(lpFile) do
begin
read(lpFile,student);
Inc(students.count);
SetLength(students.recs,students.count);
students.recs[students.count-1] := student;
end;
CloseFile(lpFile);
result := true;
except
ShowMessage( '系统异常,无效文件或文件读写错误! ');
end;
end;