Thread: Comparing Pointer types in C

  1. #16
    Registered User
    Join Date
    Jul 2008
    Posts
    1

    Wink so what are they already?

    -a1, a2, and a3 are int pointers, right? However, we can 'consider' them to be arrays. Am I okay with this here?

    -a1 and ptr2ptr are NOT of the same type, because ptr2ptr is a pointer to a pointer (it uses double indirection), and a1 is a pointer (using single indirection). ptr2ptr is a bit more 'wild' of a type than a1. ***AM I OKAY WITH THIS HERE***???

  2. #17
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by sudocat View Post
    -a1, a2, and a3 are int pointers, right? However, we can 'consider' them to be arrays. Am I okay with this here?
    You can use array notation on them, yes. Apart from type (pointer-to-integer vs. array), they are indistinguishable (guaranteed to be laid out in memory exactly the same, for instance).

    Quote Originally Posted by sudocat View Post
    -a1 and ptr2ptr are NOT of the same type, because ptr2ptr is a pointer to a pointer (it uses double indirection), and a1 is a pointer (using single indirection). ptr2ptr is a bit more 'wild' of a type than a1. ***AM I OKAY WITH THIS HERE***???
    "Wild" is not a term I would ever use to describe a variable in a computer program. Put it this way: a1 is a pointer to an integer, it can point to things like "5", and "8". ptr2ptr is a pointer to a (pointer to an integer) -- it can't point to things like "5" and "8", but it can point to things like a1.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Why does C need pointer conversion
    By password636 in forum C Programming
    Replies: 2
    Last Post: 04-10-2009, 07:33 AM
  2. Ban pointers or references on classes?
    By Elysia in forum C++ Programming
    Replies: 89
    Last Post: 10-30-2007, 03:20 AM
  3. Question About Pointer To Pointer
    By BlitzPackage in forum C++ Programming
    Replies: 2
    Last Post: 09-19-2005, 10:19 PM
  4. Could somebody please help me with this C program
    By brett73 in forum C Programming
    Replies: 6
    Last Post: 11-25-2004, 02:19 AM
  5. incompatible pointer types
    By mart_man00 in forum C Programming
    Replies: 3
    Last Post: 04-20-2003, 08:32 PM