Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 775329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:16:18+00:00 2026-05-14T19:16:18+00:00

I think I understand references and pointers pretty well. Here is what I (think

  • 0

I think I understand references and pointers pretty well. Here is what I (think I) know:

int i = 5; //i is a primitive type, the value is 5, i do not know the address.
int *ptr;  //a pointer to an int. i have no way if knowing the value yet.
ptr = &i;  //now i have an address for the value of i (called ptr)
*ptr = 10; //Go to the value in ptr, use it to find a location and store 10 there

Please feel free to comment or correct these statements.

Now I’m trying to make the jump to arrays of pointers. Here is what I do not know:

char **char_ptrs = new char *[50];
Node **node_ptrs = new Node *[50];

My understanding is that I have 2 arrays of pointers, one set of pointers to chars and one to nodes. So if I wanted to set the values, I would do something like this:

char_ptrs[0] = new char[20];
node_ptrs[0] = new Node;

Now I have a pointer, in the 0 position of my array, in each respective array. Again, feel free to comment here if I’m confused.

So, what does the ** operator do? Likewise, what is putting a single * next to the instantiation doing (*[50])? (what is that called exactly, instantiation?)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T19:16:18+00:00Added an answer on May 14, 2026 at 7:16 pm

    A few comments:

    *ptr = 10; // Doesn't need to "go get" the value. Just overwrites it.
    

    Also:

    char **char_ptrs = new char *[50];
    Node **node_ptrs = new Node *[50];
    

    It is easier to think that you have two arrays. However, technically (and as far as the compiler is concerned) what you have is two pointers. One is a pointer to a (pointer to a char) and the other is a pointer to a (pointer to a node).

    This is easily seen by the declarations of your variables, which, by the way, can be most easily read right-to-left:

    char **char_ptrs
    

    Reading right to left: char_ptrs is a pointer to a pointer to char

    Putting a * next to a pointer is properly called dereferencing that pointer. Since arrays do not technically exist, operator [] on arrays is also a dereferencing operation: arr[i] is another way of writing *(arr + i). To properly understand this, you need to be familiar with pointer arithmetic.

    More than one consecutive *s: each one dereferences the result of the expression it operates on. So when writing:

    char c = **char_ptrs;
    

    what happens is:

    char_ptrs is a pointer to a pointer to a char. Dereferencing it once (for the rightmost *) gets you its value, which is a pointer to a char. Dereferencing that value (for the leftmost *) gives you its own value in turn, which is a char. In the end, c contains the value of the char stored in memory at the place where the pointer pointed to by char_ptrs (in other words, the first pointer in your array) points.

    Conversely, if you write **char_ptrs = 'a'; then you are changing the value in that memory location.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.