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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:50:02+00:00 2026-06-10T19:50:02+00:00

Please consider the following 2-D Array: int array[2][2] = { {1,2}, {3,4} }; As

  • 0

Please consider the following 2-D Array:

int array[2][2] = {
                    {1,2},
                    {3,4}
                  };

As per my understanding:
– ‘array’ represents the base address of the 2-D array (which is the same as address of the first element of the array, i.e array[0][0]).

  • The actual arrangement of a 2-D Array in memory is like a large 1-D Array only.

  • Now, I know that base address = array. Hence, I should be able to reach the Memory Block containing the element: array[0][0].

  • If I forget about the 2-D array thing & try to treat this array as a simple 1-D array:
    array[0] = *(array+0) gives the base address of the first array & NOT the element array[0][0]. Why?

  • A 2-D array does not store any memory address (like an Array of Pointers).

  • If I know the base address, I must be able to access this memory as a linear 1- Dimensional Array.

Please help me clarify this doubt.

Thanks.

  • 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-10T19:50:04+00:00Added an answer on June 10, 2026 at 7:50 pm

    Arrays are not pointers.

    In most circumstances1, an expression of type “N-element array of T” will be converted (“decay”) to an expression of type “pointer to T“, and the value of the expression will be the address of the first element of the array.

    The type of the expression array is “2-element array of 2-element array of int“. Per the rule above, this will decay to “pointer to 2-element array of int (int (*)[2]) in most circumstances. This means that the type of the expression *array (and by extension, *(array + 0) and array[0]) is “2-element array of int“, which in turn will decay to type int *.

    Thus, *(array + i) gives you the i‘th 2-element array of int following array (i.e., the first 2-element array of int is at array[0] (*(array + 0)), and the second 2-element array of int is at array[1] (*(array + 1)).

    If you want to treat array as a 1-dimensional array of int, you’ll have to do some casting gymnastics along the lines of

    int *p = (int *) array;
    int x = p[0];
    

    or

    int x = *((int *) array + 0);
    

    1. The exceptions are when the array expression is an operand of the sizeof or unary & operators, or is a string literal being used to initialize another array in a declaration.

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

Sidebar

Related Questions

Please consider the following simple use case: public class Foo { public virtual int
Please consider the following SQL Server table and stored procedure. create table customers(cusnum int,
please consider the following: I have a queue of objects represented as an array.
Please consider following schema CREATE table articles ( id Int UNSIGNED NOT NULL AUTO_INCREMENT,
Please consider the following code: typedef struct { int type; } object_t; typedef struct
Please consider the following test program (using scala 2.9.0.1) object test { def main(args:Array[String])
please consider following code #include <iostream> using namespace std; class Digit { private: int
Please consider following code: 1. uint16 a = 0x0001; if(a < 0x0002) { //
Please consider the following code: mpz_t x, n, out; mpz_init_set_ui(x, 2UL); mpz_init_set_ui(n, 7UL); mpz_init(out);
Please consider the following code: public class Person ( public string FirstName {get; set;}

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.