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

  • Home
  • SEARCH
  • 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 6800765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:00:36+00:00 2026-05-26T19:00:36+00:00

Can anyone provide me with a formula so that I can understand the memory

  • 0

Can anyone provide me with a formula so that I can understand the memory representation of an n-dimensional(n>=2) array like this “How_are_two-dimensional_arrays_represented_in_memory”?

This calculation is applicable for 2D-arrays only.

How to calculate, suppose, a 5D array?

Ok….

I think I found the answer: Array_data_structure#Two-dimensional_arrays

  • 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-26T19:00:36+00:00Added an answer on May 26, 2026 at 7:00 pm

    A 2-dimensional array in C is nothing more or less than an array of arrays. A 3-dimensional array is an array of arrays of arrays. And so on.

    The relevant section from the C99 standard is 6.5.2.1, “Array subscripting”:

    Successive subscript operators designate an element of a
    multidimensional array object. If E is an n-dimensional array
    (n ≥ 2) with dimensions i × j × . . . × k, then E (used as
    other than an lvalue) is converted to a pointer to an (n −
    1)-dimensional array with dimensions j × . . . × k. If the unary *
    operator is applied to this pointer explicitly, or implicitly as a
    result of subscripting, the result is the pointed-to (n −
    1)-dimensional array, which itself is converted into a pointer if used
    as other than an lvalue. It follows from this that arrays are stored
    in row-major order (last subscript varies fastest).

    Some confusion is caused by the fact that the indexing operator is defined in terms of pointer arithmetic. This does not imply that arrays are “really pointers” — and in fact they very definitely are not. Declaring an array object does not create any pointer objects at all (unless of course it’s an array of pointers). But an expression that refers to the array usually (but not always) “decays” to a pointer to the array’s first element (that’s a pointer value, not a pointer object).

    Now simple array objects, of however many dimensions, are quite inflexible. Prior to C99, all array objects had to be of a fixed size determined at compile time. C99 introduced variable-length arrays (VLAs), but even so a VLA’s size is fixed when it’s declared (and not all compilers support VLAs, even 12 years after the C99 standard was issued).

    If you need something more flexible, a common approach is to declare a pointer to the element type, and then allocate an array using malloc() and have the pointer point to the array’s first element:

    int *ptr = malloc(N * sizeof *ptr);
    if (ptr == NULL) /* handle allocation failure */
    

    This lets you refer to elements of the heap-allocated array using the same syntax you’d use for a declared fixed-size array object, but in arr[i] the expression arr decays to a pointer, whereas in ptr[i] `ptr is already a pointer.

    The same thing can be extended to higher dimensions. You can allocate an array of pointers, and then initialize each pointer to point to the beginning of an allocated array of whatever.

    This gives you something that acts very much like a 2-dimensional (or more) array, but you have to manage the memory yourself; that’s the price of the greater flexibility.

    Strictly speaking, this is not a 2-dimensional array. A 2-dimensional array, as I said above, is only an array of arrays. It’s probably not entirely unreasonable to think of it as a 2-D array, but that conflicts with the usage in the C Standard; it’s similar to referring to a linked list as a 1-D array.

    The comp.lang.c FAQ is a good resource; section 6, which covers arrays and pointers, is particularly excellent.

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

Sidebar

Related Questions

I know this is not possible but can anyone provide a theory as to
Can anyone provide an source that says that unit testing is not always done
In reference to the accepted solution in: SO:expression_evaluator Can anyone provide a version that
Can anyone provide any input on this error. I am trying to insert into
Can anyone provide me the query in sql server to extract the tables that
Can anyone provide me an example WinForms application that implements the concept of User
Can anyone provide a specific example showing Javascript's prototypal inheritance that demonstrates when it's
Can anyone provide some real examples as to how best to keep script files
Can anyone provide some pseudo code for a roulette selection function? How would I
Can anyone provide a clear explanation / example of what these functions do, and

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.