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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:18:21+00:00 2026-05-20T09:18:21+00:00

Here is a code which print the address of the first element of an

  • 0

Here is a code which print the address of the first element of an 2D array followed by an addition of 1. Though all 4 base addresses are same but their addition with 1 is obviously not giving the same result due the their different “types”. I can figure out the type for some(in case they are correct) but not for all.

int main()
{
    int array[4][3];
    printf("array %u\n",array);   //of type int(*)[3]
    printf("array+1 %u\n",array+1);
    printf("&array %u\n",&array);   //....???
    printf("&array+1 %u\n",&array+1);
    printf("array[0] %u\n",array[0]);    //of type int*
    printf("array[0]+1 %u\n",array[0]+1);
    printf("&array[0] %u\n",&array[0]); //....???
    printf("&array[0]+1 %u\n",&array[0]+1);
} 

Can you explain the “type” of each base address in detail in order to understand the pointer arithmetic involved after adding 1. A sample output for gcc machine is given below for quick reference.

array       3214383040 
array+1     3214383052 
&array      3214383040 
&array+1    3214383088 
array[0]    3214383040 
array[0]+1  3214383044 
&array[0]   3214383040 
&array[0]+1 3214383052 
  • 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-20T09:18:22+00:00Added an answer on May 20, 2026 at 9:18 am

    Having int array[4][3]; the following applies

    array is an array with 4 elements. Each element is an array with 3 ints. In most circumstances using the name by itself makes the array decay to a pointer to its first element; then array becomes a pointer to arrays of 3 ints

    array + 1 is a pointer to an array of 3 ints. Here array decays to pointer and the 1 refers to array of 3 int

    &array is the address of the whole array. It points to objects of type array of 4 arrays of 3 ints

    &array + 1 is the 2nd (which really does not exist) element of a pseudo-array of arrays of 4 arrays of 3 ints

    array[0] is an array of 3 ints. It usually decays to a pointer to the first element

    array[0] + 1 points to the 2nd int in array[0]

    &array[0] address of an object of type array of 3 ints

    &array[0]+1 2nd element of an array of arrays of 3 ints

    PS. I’ll try to make a drawing (ASCII) after lunch.


    Hmmm … drawing is tough 🙂

    Before trying, I thought I could make a better drawing.
    This is the best I could come up with …

    
        int array[4][3]        ........[aaabbbcccddd]........
                                  where aaa, bbb, ccc, ddd are arrays of 3 ints'
    
        the [] represent the object itself; the {} represent pointers.
    
        array (object)         ........[AAABBBCCCDDD]........       int[4][3]
        array (decayed)    ==> ........{aaa}bbbcccddd........       int(*)[3]
    
        array + 1          ==> ........aaa{bbb}cccddd........       int(*)[3]
    
        &array             ==> ........{aaabbbcccddd}........       int(*)[4][3]
        &array + 1         ==> ........aaabbbcccddd{xxxxxxxxxxxx}........       int(*)[4][3]
    
        array[0] (object)      ........[AAA]bbbcccddd........       int[3]
        array[0] (decayed) ==> ........{a}aabbbcccddd........       int*
    
        array[0] + 1       ==> ........a{a}abbbcccddd........       int*
    
        &array[0]          ==> ........{aaa}bbbcccddd........       int(*)[3]
        &array[0] + 1      ==> ........aaa{bbb}cccddd........       int(*)[3]
    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the code which test in IE8: var stack = []; function test()
Here is jquery code which hides my table cells with the ID of .style2:
Here is my code which checks if the file exists : #include<stdio.h> #include<zlib.h> #include<unistd.h>
Here is my code which is doing the conversion from hex to decimal. The
I have some code here which works perfectly in firefox but not in chrome
I have this piece of Open MP code here which performs an integeration of
I need help with a weird runtime error. Here's the code which gives it:
i have this quick issue please. I have this code here which permits me
I'm just trying out the allegro library, and here is the code which I've
I want to create a dynamic Expression<Func<T,Y>> . Here is the code which works

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.