On Thu 11 Feb 2010, Rainer Stratmann wrote: > 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'
c := (p+x)^; // why would someone use square brackets for that? Of course, if you are actually working with a string, there is no need to use pointers. c := s[5]; // remember strings are 1-indexed You can also increment... inc (p, 4); c := p^; I might make a second pointer, q, and increment that, so p can stay in place. ~David. _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal