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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:46:54+00:00 2026-06-14T00:46:54+00:00

This a very basic concept. But, I get confused generally. Help me. Case 1:

  • 0

This a very basic concept. But, I get confused generally. Help me.

Case 1:

For the below code:

int oneDArray[] = {1,2,3};
cout<<&oneDArray<<endl;
cout<<oneDArray<<endl;
cout<<&oneDArray+1<<endl;
cout<<oneDArray+1<<endl;

Output is :

0x28fef4
0x28fef4
0x28ff00
0x28fef8

Why is there a difference in the incremented values?

Case 2:

  int arr[2][3] = {{1,2,3}, {4,5,6}};
  cout<<&arr<<endl;
  cout<<arr<<endl;
  cout<<*arr<<endl;

  cout<<&arr+1<<endl;
  cout<<arr+1<<endl;
  cout<<*arr+1<<endl;

Output is:

0x28fee8
0x28fee8
0x28fee8
0x28ff00
0x28fef4
0x28feec

Why is the output same for arr & *arr? (How it works internally)
Why is there a difference in the incremented 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-06-14T00:46:56+00:00Added an answer on June 14, 2026 at 12:46 am

    For your single-dimension array:

    //starting at memory address: 0x28FEF4
    int My_Array[3] = {1,2,3};
    
    //memory dumping, each 'int' element takes 4 bytes, 
    //high bytes are at higher addresses
    0x28FEF4 01 00 00 00
    0x28FEF8 02 00 00 00
    0x28FEFC 03 00 00 00
    

    This is the translation from C language to English language:

    My_Array     = (address) of-the (first-byte) of (My_Array)
    My_Array[0]  = (value)   of-the (element-at-index-0)
    My_Array[k]  = (value)   of-the (element-at-index-k)
    
    &My_Array    = (address) of-the (first-byte) of (My_Array)
    &My_Array[0] = (address) of-the (first-byte) of (element-at-index-0)
    &My_Array[k] = (address) of-the (first-byte) of (element-at-index-k)
    
    *My_Array    = (value) pointed-by (My_Array)
    *My_Array[0] = (value) pointed-by (My_Array[0])
    *My_Array[k] = (value) pointed-by (My_Array[k])
    
    The values of 'My_Array' and '&My_Array' are always identical for array type
    but there's a difference when using them with mathematical operators.
    My_Array is a pointer to 'int' type, while &My_Array is a pointer 
    to 'int[3]' type.  When incremented, the values added in are sizeof(int) 
    and sizeof(int[3]) respectively.
    
    The last two notations: *My_Array[0] and *My_Array[k]
    are valid in mathematical sense but not valid in C language when using 
    with single-dimension array because C langugae doesn't allow using 
    'int' value as pointer.
    

    Explanation for the output result of your case 1:

    (&My_Array) is identical to (My_Array)  = 
    0x28FEF4
    
    (My_Array)  is identical to (&My_Array) = 
    0x28FEF4
    
    (&My_Array+1) = 0x28FEF4 + sizeof(int[3]) = 0x28FEF4 + 12 = 
    0x28FF00
    
    (My_Array+1)  = 0x28FEF4 + sizeof(int)    = 0x28FEF4 + 4  = 
    0x28FEF8
    

    Apply my notes above to your second case, with these attentions:

    (1) Value of element in single dimension array is the base type. Eg:
        int My_Array[3]; //base type is 'int'
    
    (2) Value of element in multiple dimension array is either pointer 
        or base type. Eg:
        int My_Array[2][3][4]; //base type is 'int'
    
        My_Array is a pointer to 'int' type        
        My_Array[i] is a pointer to 'int' type
        My_Array[i][j] is a pointer to 'int' type
        My_Array[i][j][k] is an 'int' value
    
        &My_Array is a pointer to 'int[2][3][4]'
        &My_Array[i] is a pointer to 'int[3][4]' 
        &My_Array[i][j] is a pointer to 'int[4]'
        &My_Array[i][j][k] is a pointer to 'int'
    
    (3) Values of 'My_Array' and '&My_Array' are always equal,
        however, when dealing with operators, they work differently.
        Eg.
        int My_Array[2][3][4]; //base type is 'int'
    
        '&My_Array' here is a pointer to 'int[2][3][4]', but
        'My_Array' is a pointer to base type 'int'.
    
    (4) A pointer is always incremented by the size of the type 
        that it points to. 'int' has size of 4 bytes.
        Eg.
        int My_Array[2];          //type size = (2)*4
        int My_Array[2][3];       //type size = (2*3)*4
        int My_Array[2][3][4];    //type size = (2*3*4)*4
        int My_Array[2][3][4][5]; //type size = (2*3*4*5)*4
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a very basic concept, but something I have never been able to
This is very basic stuff , but here goes. I find that I am
This is very basic magento question i guess. I want to first get all
This is very basic question from programming point of view but as I am
This seems very basic and I must be missing something, but here goes anyways...
Apparently this is very basic jQuery but im on a time crunch and I
This is a very basic question...quite embarassing, but here goes: I have a Stopwatch
I'm using this very basic code to make InfoWindow a 'singleton' and open it
This question seems to be very basic, but I don't know why, there is
I've got this to work using a very basic example(outlined below) and I want

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.