[fpc-pascal] Pointers

Rainer Stratmann RainerStratmann at t-online.de
Thu Feb 11 21:53:59 CET 2010


Am Thursday 11 February 2010 21:24:03 schrieb Ralf A. Quint:
> At 12:07 PM 2/11/2010, Jonas Maebe wrote:
> >On 11 Feb 2010, at 18:17, Rainer Stratmann wrote:
> >>In the past with the turbopascal compiler and other always sizeof
> >>byte was
> >>added.
> >
> >That is not true. This program prints "2" when compiled under Turbo
> >Pascal:
>
> I am fairly certain that he confuses this with the special case of
> applying sizeof() to a string type, where you always get one byte
> more (the preceding length byte) than the string type has been
> defined, for example SizeOf (String [80]) will return 81, 80 bytes
> reserved for the contents plus the length byte...
>
> Ralf

How can I have access to position 4 of a pointer?

var
 p : pbyte;
 c : char;
 s : ansistring;
 x : longint;

...

 s := 'Hello';

 p := @s;

 x := 4;  // 4th position

 c :=  [p+x]^ ??? how to get access to the 'o'
 




More information about the fpc-pascal mailing list