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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:43:52+00:00 2026-06-12T21:43:52+00:00

Please consider the following piece of code #include <stdio.h> #define ROW_SIZE 2 #define COL_SIZE

  • 0

Please consider the following piece of code

#include <stdio.h>
#define ROW_SIZE 2
#define COL_SIZE 2

int main()
{
   int a[ROW_SIZE][COL_SIZE]={{1,2},{3,4}};

   // Base address:Pointer to the first element a 1D array
   printf("Base address of array:%p\n",a);

   //The value at the base address: should be the address of 1st 1D array
   printf("Value at the Base address:%p\n",*a);

   return 0;
}

Output obtained:

Sample Output:
Base address of array:0xbff77434
Value at the Base address:0xbff77434

Somehow, I am failing to understand the concept of the base address of a 2D array and the value at the base address which is inturn an address to a 1D array being same. Please explain.

  • 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-12T21:43:53+00:00Added an answer on June 12, 2026 at 9:43 pm

    Arrays aren’t pointers, and in C, a multidimensional array is just an array of arrays. In many contexts, using the name of an array “decays” into a pointer to the first element of that array. That’s what happens in both of your print statements. In the first case:

    printf("Base address of array:%p\n",a);
    

    a becomes a pointer to the first element of the array – that is, a pointer to the first row of your array. In your case, that means you get a pointer of type int (*)[2].

    In the second case:

    printf("Value at the Base address:%p\n",*a);
    

    The same decaying happens, but then you dereference that pointer. That means you dereferenced that int (*)[2] pointer to the first row, leaving you with an array again (the first row). That array itself decays into a pointer to its first element, giving you a resulting int * pointer (to the first element of the first row).

    In both cases the address is the same, since that’s how the array is laid out in memory. If we said your 2D array started at address 0, it would look like this (assuming a 4 byte int type):

     Address       Value
        0            1
        4            2
        8            3
       12            4
    

    The address of the first row and the address of the first element of the first row are both 0.

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

Sidebar

Related Questions

Please consider the following code: #include <stdio.h> int main() { static int counter=5; printf
Please consider the following piece of code: int main() { typedef boost::ptr_vector<int> ptr_vector; ptr_vector
please consider following code #include <iostream> using namespace std; class Digit { private: int
Please consider the following piece of code, which throws three different exceptions (namely, System.Configuration.ConfigurationErrorsException
Please consider the following code: #include <iostream> #include <typeinfo> template< typename Type > void
Please consider the following code: typedef struct { int type; } object_t; typedef struct
Please consider the following fork() / SIGCHLD pseudo-code. // main program excerpt for (;;)
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.