Hi all,
Is this a compiler error or a programming error we I get junk in B in =the procedure the values are good enough. see below.
program
Type MyArray ( m, n ) = array [ 1..m, 1..n ] of Integer;
Var B: ^MyArray;
[...] Procedure BuildArray(var NewArray : MyArray; k: Integer); begin
New ( NewArray, k, k); [...] For i := 1 to k NewArray^[3 ,k ]:= i+k; [...] end;
begin buildArray(B, 10); For i := 1 to 10 begin Writeln(b^[3,i]; end;
Dispose ( B ); [...] end.
Klaus F. Østergaard Laser Technical Services A/S Sneppevang 3 3450 Allerød tel +45 48 17 61 61 fax +45 48 17 10 65 e-mail Laser@lasertech.dk
Klaus Friis Ãstergaard a écrit : Is this a compiler error or a programming error we I get junk in B in the procedure the values are good enough. see below.
You have extracted some lines from a longer program and probably introduced errors. Check that the following corrected program works (it does for me on djgpp)
program bug;
Type MyArray ( m, n : integer ) = array [ 1..m, 1..n ] of Integer; pMyArray = ^MyArray;
Var B: pMyArray; i: integer;
Procedure BuildArray(var pNewArray : pMyArray; k: Integer); var i:integer; begin
New ( pNewArray, k, k);
For i := 1 to k do pNewArray^[3 ,i ]:= i+k;
end;
begin buildArray(B, 10); For i := 1 to 10 do begin Writeln(b^[3,i]); end;
Dispose ( B ); end.