我正在尝试使用简单的字符串和整数记录的以下代码:
program Progrecords;
Type
Progrec = Record
pname : string;
pnum : integer;
end;
var
Progs : Array of Progrec;
aprog, pp: Progrec;
begin
aprog.pname := 'abc';
aprog.pnum := 4;
Progs[0] := aprog;
aprog.pname := 'def';
aprog.pnum := 6;
Progs[1] := aprog;
for pp in Progs do begin
writeln('Name: ',pp.pname, '; Num: ', pp.pnum);
end;
end.
它可以编译,但会给出运行时错误:
$ fpc rnrecords.pas && ./rnrecords
Free Pascal Compiler version 3.0.0+dfsg-11+deb9u1 [2017/06/10] for x86_64
Copyright (c) 1993-2015 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling rnrecords.pas
rnrecords.pas(17,2) Warning: Variable "Progs" of a managed type does not seem to be initialized
Linking rnrecords
/usr/bin/ld.bfd: warning: link.res contains output sections; did you forget -T?
27 lines compiled, 0.1 sec
1 warning(s) issued
Runtime error 216 at $0000000000400226
$0000000000400226
$000000000040018C
我正在使用fpc版本3.0.0的Debian Stable Linux
问题在哪里,如何解决?谢谢你的帮助。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句