[fpc-pascal] Pointers

Ralf A. Quint FreeDOS at gmx.net
Thu Feb 11 22:29:25 CET 2010


At 12:53 PM 2/11/2010, Rainer Stratmann wrote:
> > 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?

By using Pascal and not C! <LOL>

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


begin

  s := 'Hello';
  p := @s;
  x := 5;  // 5th position!!!!


  c :=  Char (ANSIString (p^)[x]);
  WriteLn ('Character No.',x,' is ',c);
end.

Ralf 




More information about the fpc-pascal mailing list