var
s:string;h:thandle;
begin
setlength(s,10);
if opendialog1.Execute then
begin
h:=fileopen(opendialog1.Filename,fmopenread);
fileread(h,s,10);
fileclose(h);
showmessage(s);
end;
end;运行期错误。????
s:string;h:thandle;
begin
setlength(s,10);
if opendialog1.Execute then
begin
h:=fileopen(opendialog1.Filename,fmopenread);
fileread(h,s,10);
fileclose(h);
showmessage(s);
end;
end;运行期错误。????
type
TMyRec=record
i:integer;
c:char;
a:array[1..10] of char;
s:string;
end;
///////////////
var
s:array[1..10] of char;
h:thandle;
a:tmyrec;
begin
//setlength(s,10);if opendialog1.Execute then
begin
h:=fileopen(opendialog1.Filename,fmopenread);
fileread(h,a,10);
fileclose(h);
msg(a.s);
end;
end;
0A
其中 Buffer 应该是指针,不能是具体变量
—————————————————————————————————
MaximStr := '宠辱不惊,看庭前花开花落,去留无意;
毁誉由人,望天上云卷云舒,聚散任风。';
if Not Assigned(I) then
I := TI.Create(Nil);
I.Maxim := MaximStr;
—————————————————————————————————
begin
h:=fileopen(opendialog1.Filename,fmopenread);
fileread(h,a.a,10);
fileclose(h);
msg(a.s);
end;
—————————————————————————————————
MaximStr := '宠辱不惊,看庭前花开花落,去留无意;
毁誉由人,望天上云卷云舒,聚散任风。';
if Not Assigned(I) then
I := TI.Create(Nil);
I.Maxim := MaximStr;
—————————————————————————————————
fileread(h,a.c{或者a.i},100)都可以呀。a:array of char;if opendialog1.Execute then
begin
h:=fileopen(opendialog1.Filename,fmopenread);
fileread(h,a,10);
fileclose(h);
end;里面的a不是指针?
如
var 首地址
P: Pointer; P^
P: PChar P^
//只要是指针类型就是 P^
S: string S[1];
Arr: array [0..10] of Char; Arr[0] or Arr
Arr: array [0..10] of TDataRecord Arr[0] or Arr
//只要是array 类型就是 Arr[0] or Arr
var s: PChar;
h:THandle;
begin
GetMem(s,256); //分配地址,不能少
h := FileOpen('H:\Delphi\函数.txt',fmOpenRead);
FileRead(h,s^,256); //^不能少,取地址
end;
出现运行骑错误,一般都是没有分配地址。
—————————————————————————————————
MaximStr := '宠辱不惊,看庭前花开花落,去留无意;
毁誉由人,望天上云卷云舒,聚散任风。';
if Not Assigned(I) then
I := TI.Create(Nil);
I.Maxim := MaximStr;
—————————————————————————————————
var s: PChar;
h:THandle;
begin
GetMem(s,256); //分配地址,不能少
h := FileOpen('H:\Delphi\函数.txt',fmOpenRead);
FileRead(h,s^,256); //^不能少,取地址
end;
出现运行骑错误,一般都是没有分配地址。
—————————————————————————————————
MaximStr := '宠辱不惊,看庭前花开花落,去留无意;
毁誉由人,望天上云卷云舒,聚散任风。';
if Not Assigned(I) then
I := TI.Create(Nil);
I.Maxim := MaximStr;
—————————————————————————————————