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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:47:27+00:00 2026-05-27T17:47:27+00:00

I have a basic doubt in 2D arrays (C Language). Consider a declaration of

  • 0

I have a basic doubt in 2D arrays (C Language). Consider a declaration of a 2D array as follows

int array[3][5];

Now when I do the following, the output of both th below printf’s is the same:

printf("%u\n", array);
printf("%u\n", *(array));

Now when try to to the following:

printf("%u\n", array+1);
printf("%u\n", *(array)+1);

The outputs are different. I get that the 2nd printf refers to array[0][1] and the first one to array[1][0]. How does this work? array is a pointer to what?

Thanks in advance

  • 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-27T17:47:27+00:00Added an answer on May 27, 2026 at 5:47 pm

    Arrays are not pointers. Ignore any answer, book, or tutorial that tries to tell you otherwise.

    An expression of array type, in most contexts, is converted (at compile time) into a pointer to the array’s first element. The exceptions are:

    • The operand of sizeof (sizeof arr yields the size of the array, not the size of a pointer)
    • The operand of unary & (&arr yields the address of the array, not of its first element — same memory location, different type). This is particularly relevant to your example.
    • A string literal in an initializer used to initialize an array object (char s[6] = "hello"; doesn’t copy the address of the string literal, it copies its value)

    A 2-dimensional array is nothing more or less than an array of arrays. There are other data structures that can be used with the same x[y][z] syntax, but they’re not true 2-dimensional arrays. Yours is.

    The [] indexing operator is defined in terms of pointer arithmetic. x[y] means *(x+y).

    The behavior of your code follows from these rules.

    Read section 6 of the comp.lang.c FAQ. It’s the best explanation of this stuff I’ve seen.

    And don’t use "%u" to print pointer values; convert to void* and use "%p".

    printf("%p\n", (void*)array);
    printf("%p\n", (void*)*(array));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a basic doubt that, How can we have both CLR's on a
I have a doubt on basic C++ usage. The code below, compiled with gcc/LInux,
I have a basic doubt, when I was analyzing object and reference. int a;
I have a very basic doubt regarding the method that gets executed when app
Well, I think I have a very basic doubt here: I'm developing an app
I have basic doubt regarding executable stored in ROM. As I know the executable
I have a basic doubt. Internally how are events represented as methods or as
I have one basic doubt. I have a process which uses a shared library.
I have a very basic doubt regarding cloud computing that is catching up pretty
I have a very basic doubt here. I have two very simple C codes

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.