Thread: Adress of a pointer.

  1. #1
    Registered User
    Join Date
    Jul 2007

    Adress of a pointer.

    I am trying to assign adress of a pointer to a pointer.

    so far:

    #include <stdio.h>
    #include <string.h>
    int main()
    	int *ptr;
    	int y;
    	int **ptr2;
    	printf("%p   %p",ptr,ptr2);
    	return 0;
    So According to what I think , every pointer has also an adress of their own which has the information about the adress that pointer points. Am I true?

  2. #2
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    United States
    You're right.

    A pointer is a variable that contains a memory address as its value, just like ints have an integer as a value. And since pointers take up small parts of memory like other types of variables, information about the pointer itself is stored at an address that is very different from its value. So if that made sense, then yeah, pointers can have the location of other pointers as values.

    But the thing is, no variable is aware of its own address. Hence, C has an operator that will fetch it for you.

    Dereferencing T *p is something different. It's another operator that returns the T stored in its value.

  3. #3
    Registered User
    Join Date
    Jul 2007
    Thanks perfect gentleman =)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. What is a virtual function pointer?
    By ting in forum C++ Programming
    Replies: 4
    Last Post: 03-05-2008, 02:36 AM
  2. Pointer (adress) question.
    By omnificient in forum C Programming
    Replies: 22
    Last Post: 02-27-2008, 08:49 AM
  3. How did you master pointers?
    By Afrinux in forum C Programming
    Replies: 15
    Last Post: 01-17-2006, 08:23 PM
  4. scope of a pointer?
    By Syneris in forum C++ Programming
    Replies: 6
    Last Post: 12-29-2005, 09:40 PM
  5. want to assign myself the adress of a pointer
    By Unregistered in forum C++ Programming
    Replies: 9
    Last Post: 07-22-2002, 02:19 PM