[fpc-pascal] problem with array of string
Adam Naumowicz
adamn at math.uwb.edu.pl
Mon Dec 20 22:53:14 CET 2004
On Mon, 20 Dec 2004 Michael.VanCanneyt at Wisa.be wrote:
> On Mon, 20 Dec 2004, Dariusz Mazur wrote:
>
> > I have problem with two dimension array of string
> >
> > my program:
> >
> > procedure testlinie;
> > var
> > linie : array[0..1,0..100] of shortstring;
> > i,ii : integer;
> > begin
> > fillchar(linie,sizeof(linie),0);
> > for i := 0 to 1 do begin
> > for ii:= 1 to 10 do begin
> > linie[i,ii]:= linie[i,ii]+char(64+ii);
> > writeln(i:5,ii:5,linie[i,ii]) ;
> >
> > end;
> > end;
> > end;
> >
> > during execution output is:
> > 0 1 A
> > 0 2 B
> > 0 3 C etc.
> >
> > but should be:
> > 0 1 A
> > 0 2 AB
> > 0 3 ABC
> >
> > on Delphi all works OK.
>
> I seriously doubt this:
Me either, but it seems that there is a simple typo in the inner loop
(ii instead of ii-1), so it should go like that:
for ii:= 1 to 10 do begin
linie[i,ii]:= linie[i,ii-1]+char(64+ii);
writeln(i:5,ii:5,linie[i,ii]) ;
end;
Best,
Adam
More information about the fpc-pascal
mailing list