Pointer Operators

The relational operators <, >, <=, and >= can take operands of type PChar and PWideChar (see Relational operators). The following operators also take pointers as operands. For more information about pointers, see Pointers and pointer types.

Character-pointer operators

Operator Operation Operand Types Result Type Example


pointer addition character pointer, integercharacter pointer P + I

- pointer subtraction character pointer, integercharacter pointer, integerP - Q


pointer dereferencepointer

base type of pointer PA


equality pointer

Boolean P = Q


inequality pointer

Boolean P <> Q

The a operator dereferences a pointer. Its operand can be a pointer of any type except the generic Pointer, which must be typecast before dereferencing.

p = q is True just in case p and q point to the same address; otherwise, p <> q is True.

You can use the + and - operators to increment and decrement the offset of a character pointer. You can also use - to calculate the difference between the offsets of two character pointers. The following rules apply.

  • If I is an integer and p is a character pointer, then p + I adds I to the address given by p; that is, it returns a pointer to the address I characters after p. (The expression I + p is equivalent to p + I.) p - I subtracts I from the address given by p; that is, it returns a pointer to the address I characters before p. This is true for PChar pointers; for PWideChar pointers p + I adds sizeOf (WideChar) to P.
  • If p and q are both character pointers, then p - q computes the difference between the address given by p (the higher address) and the address given by q (the lower address); that is, it returns an integer denoting the number of characters between p and q. p + q is not defined.
Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook

Post a comment