How to declare a pointer that points to another pointer?

This is a discussion on How to declare a pointer that points to another pointer? within the C Programming forums, part of the General Programming Boards category; Hi all: It is easy to declare a pointer that points to a integer: int *ptr = NULL; My question ...

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    26

    Question How to declare a pointer that points to another pointer?

    Hi all:

    It is easy to declare a pointer that points to a integer:
    int *ptr = NULL;

    My question is how to declare a pointer that points to another pointer, basically a pointer that points to a memory address?

    Thank you

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    23,618
    Consider this:
    Code:
    int x = 123;
    int *ptr = &x;
    int **p2ptr = &ptr;
    Further levels of indirection (e.g., pointer to pointer to pointer) are of course possible.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems passing a file pointer to functions
    By smitchell in forum C Programming
    Replies: 4
    Last Post: 09-30-2008, 02:29 PM
  2. Replies: 14
    Last Post: 11-19-2007, 09:28 AM
  3. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 03:36 AM
  4. Could somebody please help me with this C program
    By brett73 in forum C Programming
    Replies: 6
    Last Post: 11-25-2004, 01:19 AM
  5. Pointer points to struct pointer
    By gogo in forum C Programming
    Replies: 4
    Last Post: 11-27-2001, 11:14 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21