[fpc-pascal]I don't Understand Array
Michael.VanCanneyt at Wisa.be
Michael.VanCanneyt at Wisa.be
Thu Feb 15 19:33:01 CET 2001
On Thu, 15 Feb 2001, [iso-8859-1] Luis Del Aguila Mejía wrote:
> When declare a Array variable with character, The compiler add 3 character,
> see the next code :
>
Turn on range checking and you will get a range check error.
What you get is completely normal; the code accesses
the variables 'before' m[0]; If range checking is off, this is allowed.
Michael.
> var
> antes:char;
> m : array [0..3] of char;
> despues : char;
> begin
> antes:='a';
> m:='hola';
> despues:='z';
> Writeln('m[-4] : ',m[-4]); // variable antes
> Writeln('m[-3] : ',m[-3]); // 1 byte
> Writeln('m[-2] : ',m[-2]); // 1 byte
> Writeln('m[-1] : ',m[-1]); // 1 byte
> Writeln('m[0] : ',m[0]); //h
> Writeln('m[1] : ',m[1]); //o
> Writeln('m[2] : ',m[2]); //l
> Writeln('m[3] : ',m[3]); //a
> Writeln('m[4] : ',m[4]); //z variable despues
> Writeln('Tamanio de m : ',Sizeof(m));
> Write('Presione Enter ... ');
> Readln()
> end;
>
> Att.
> Luis Del Aguila
> aguila3000 at terra.com.pe
>
>
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
More information about the fpc-pascal
mailing list