Results 1 to 5 of 5

Thread: Delphi pointer comparation

  1. #1

    Delphi pointer comparation

    How is possible to compare two pointer?

    In c is possible to have:

    int *P1;
    int *P2;

    if (P1<P2)
    //some stuff

    Thanks
    Sesilla

  2. #2
    You can cast it to a Cardinal, depending on your compiler version.
    From brazil (:

    Pascal pownz!

  3. #3
    You can adjust pointers by casting them to PtrInt on FreePascal or NativeInt on Delphi.

    However, I would advice that you change your code so that you don't need this comparison. For instance, try comparing actual indices to an array instead. The way you want to compare the pointers is very troublesome; it could be both unpredictable and unreliable.

  4. #4
    Quote Originally Posted by SesillaAndromeda View Post
    How is possible to compare two pointer?

    In c is possible to have:

    int *P1;
    int *P2;

    if (P1<P2)
    //some stuff

    Thanks
    Sesilla
    If you want to compare integer values the pointers 'point to', you can do this:

    Code:
    if P1^ < P2^ then
    //some stuff
    cheers,
    Paul

  5. #5

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •