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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:29:13+00:00 2026-06-04T12:29:13+00:00

Lets say we have : int A [5] [2] [3]; Now, if I do

  • 0

Lets say we have : int A [5] [2] [3];
Now, if I do : A[1][0][0] = 4; does that mean :

1.) A [1] and A [1][0] are pointers ?

2.) If A[1] is a pointer, then it will store the address of the pointer A[1][0] ?

3.) If A[1][0] is a pointer, then it will store the address of A[1][0][0] which is NOT a pointer but just a variable that stores the value of 4 ?

If the above points are correct, then why dos the following code give us the same integer address :

int main(void)
{
        int A [5] [2] [3];
    A[1][0][0]=4;

    printf("%d\n\n", A[1]);
    printf("%d\n\n", A[1][0]);
    printf("%d\n\n",&A[1][0][0]);

        system("pause");
}

Here, I am assuming that A[1] is a pointer which points to another pointer A[1][0] and hence stores the address of the pointer A[1][0]. And, A[1][0] is a pointer which points to the VARIABLE A[1][0][0] and hence stores the address of the VARIABLE A[1][0][0] .

Please help me!

  • 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-06-04T12:29:14+00:00Added an answer on June 4, 2026 at 12:29 pm

    To properly answer your question, read up on row-major order, which is how multidimensional arrays are stored in C. The Wikipedia article is a little too terse, but one of these might be more clear:

    http://webster.cs.ucr.edu/AoA/Windows/HTML/Arraysa2.html
    http://archive.gamedev.net/archive/reference/articles/article1697.html
    http://www.ibiblio.org/pub/languages/fortran/append-c.html

    There’s this SO question also.


    In direct answer to your points, assuming that you know how row-major storage works:

    int A[5][2][3] declares a contiguous region of memory that is 5*2*3 ints long: five arrays of two arrays of three ints each. The arrays are stored next to each other in linear memory, so that

    &A[0][0][0] == A
    &A[0][0][1] == A+1
    &A[0][1][0] == A+(1*3)
    &A[3][1][2] == A+(3*(2*3))+(1*3)+2
    

    A[1] is technically not a pointer but an array. It’s an int [2][3] array. But I find that much less clear to think about than considering A[5][2][3] is a flat region of memory, thirty ints long.

    A[0][0][0] is the first integer in that region. 
    A[0][0][1] is the second integer. 
    A[0][0][2] is the third integer. 
    A[0][1][0] is the fourth integer in this flat region. 
    A[0][1][1] is the fifth integer. 
    And so on until A[1][0][0] is the eleventh integer. 
    

    Therefore the address of A[1][0][0] is ten integers past A[0][0][0]; ie, &A[1][0][0] - &A[0][0][0] == 10. Because the C language is very loose about the difference between arrays and pointers, A[1] gets interpreted as if it were an address when you use it in an expression, even though it really means “the first element in an array of five arrays of two arrays of three integers” which is in turn “an array of two arrays of three integers.”

    The upshot is that A[1] doesn’t store a pointer, it is a pointer. Every memory address from &A[0][0][0] to &A[5][2][3]-1 stores an integer in your multidimensional array.

    What you’re thinking of in points (2) and (3) are arrays of pointers to arrays, which are something different.

    This is a lot easier to explain with pictures, which is why you should find a proper textbook or article on C arrays.

    In general, when learning about pointers and arrays in C, I recommend that you temporarily forget about the language itself and pretend that you are Dennis Ritchie inventing C on a PDP-11 computer with 56kb of flat RAM. Get a big sheet of graph paper, number its cells consecutively, pretend that it represents your RAM and each cell is one byte, and you can work through your pointer math with pencil and paper.

    C was invented in that environment and understanding its origins will make the modern langauge much more sensible.

    As a side note, when I tried to write this answer, Stack Overflow’s markup language repeatedly changed and screwed up the indexes in my array examples above. So if you see any numbers there that seem out of range for their arrays, it’s a mistake introduced by the editor.

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

Sidebar

Related Questions

Lets say I have an array numbers that contains the following values: int numbers
Lets say have this immutable record type: public class Record { public Record(int x,
Lets say I have table with ID int, VALUE string: ID | VALUE 1
Lets say I have two tables tblA ( tableAID INT IDENTITY(1,1), foo VARCHAR(100)) tblB
Lets say I have table named Place with columns: placeId int not null auto_increment,
Lets say i have this usercontrol public class test : UserControl { public int
Lets say I have the following MySQL structure: CREATE TABLE `domains` ( `id` INT(10)
So lets say I have TABLE1 and TABLE2. CREATE TABLE TABLE1 ( first_id int
Let's say I have a Java app which uses a (static) int constant from
This is something I never truly understood in Java. Lets say I have: int

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.