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 6720353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:12:08+00:00 2026-05-26T09:12:08+00:00

It seems the regular definition of the indirection operator doesn’t apply when it is

  • 0

It seems the regular definition of the indirection operator doesn’t apply when it is used on multi-dimensional arrays:

int arr[10][10][10];

If you dereference arr, you’ll get the same address:

(void*)arr == (void*)*arr && (void*)*arr == (void*)**arr

This makes sense though – a multi-dimensional array is just a contiguous region of memory, where the pointer points at the beginning of the memory. The compiler essentially ignores dereferences and just computes the proper offset. Use of the indirection operator seems to only preserve the abstraction of multi-dimensional arrays and make it fit with the other syntactic constructs of the language.

If you do the following:

int *** ptr = (int***) arr;

And dereference ptr, you’ll see the normal dereference behavior, where the value in the location specified by the pointer is returned. Using the above cast, you’ll read into undefined memory if you dereference the pointer more than twice.

I’m just wondering why this behavior isn’t documented in more places – that is, the difference of effect of the indirection operator on pointers to arrays vs pointers to pointers and pointers to values?

  • 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-26T09:12:08+00:00Added an answer on May 26, 2026 at 9:12 am

    Firstly, to fully understand this you must appreciate that C does not have multidimensional arrays – it has arrays of arrays. So, in your example, arr is “an array of 10 arrays of 10 arrays of 10 ints”.

    Secondly, it’s not the indirection operator that behaves differently, it’s the behaviour of expressions with array type that’s odd.

    If an expression with array type is not the subject of either the unary & or sizeof operators1, then it evaluates to a pointer to the first element of that array.

    This means that in the following expression:

    (void*)*arr == (void*)**arr
    

    On the left hand side, arr evaluates to a pointer to the first array of 10 arrays of 10 ints within arr (that is, &arr[0]). This is then dereferenced to obtain that array itself: the first sub-array within arr, arr[0]. However, since arr[0] is itself an array, this then is replaced with a pointer to it’s first element, &arr[0][0].

    On the right hand side, the above happens as per the left hand side, then that last pointer is dereferenced, obtaining arr[0][0]. This, again, is an array, so it is finally replaced with a pointer to its first element, &arr[0][0][0].

    The reason these are equal (after conversion to void *) is simply because the address of the array arr[0][0] and the address of the int arr[0][0][0] coincide, as the latter is the first member of the former. They also concide with the address of arr[0] and arr, so you also have:

    (void *)&arr == (void *)arr;
    (void *)arr == (void *)*arr;
    

    as well.


    1. ..and is not a string literal used in an initializer.

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

Sidebar

Related Questions

It seems that the choice to use string parsing vs. regular expressions comes up
I understand PCRE pretty well, but MySQL's regular expression flavor seems to get the
I am not a beginner to regular expressions, but their use in perl seems
It would seem that regular expression questions are common as each question seems to
What is the best method for using Regular Expressions within Objective-C? There seems to
Is there anyway I can clean this up with a regular expression? it seems
It seems that this is a huge source of confusion for beginners writing regular
I was reading the Java Regular Expression tutorial, and it seems only to teach
There seems to be some people that have gotten Paperclip working on a regular
This seems like it must be so simple, but regular expressions are extremely confusing

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.