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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:17:51+00:00 2026-06-07T23:17:51+00:00

Possible Duplicate: How do I use arrays in C++? Is 2d array a double

  • 0

Possible Duplicate:
How do I use arrays in C++?
Is 2d array a double pointer?
Two dimensional arrays and pointers

I know that this is a very basic question but no amount of googling cleared this for me. That’s why am posting it here.
In c++ consider the declaration int x[10];

This is a 1-dimensional array with x being the base pointer that is it contains the address of the first element of the array. So x gives me that address and *x gives the first element.

similarly for the declaration

 int x[10][20];

what kind of variable is x here. When i do

 int **z = x;

the compiler says it cannot convert int (*)[20] to int **.And why does cout<<x; and cout<<*x; give the same value??
And also if i declare an array of pointers as

 int *p[10];

then is there a difference between x and p ( in their types) ?? because when one declares int x[10] and int *p then it is valid to assign x to p but it is not so in case of two dimensional arrays? why?
Could someone please clear this for me or else provide a good resource material on this.

  • 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-07T23:17:53+00:00Added an answer on June 7, 2026 at 11:17 pm

    Arrays and pointers aren’t the same thing. In C and C++, multidimensional arrays are just “arrays of arrays”, no pointers involved.

    int x[10][20];
    

    Is an array of 10 arrays of 20 elements each. If you use x in a context where it will decay into a pointer to its first element, then you end up with a pointer to one of those 20-element arrays – that’s your int (*)[20]. Note that such a thing is not a pointer-to-a-pointer, so the conversion is impossible.

    int *p[10];
    

    is an array of 10 pointers, so yes it’s different from x.

    In particular, you may be having trouble because you seem to think arrays and pointers are the same thing – your question says:

    This is a 1-dimensional array with x being the base pointer that is it contains the address of the first element of the array. So x gives me that address and *x gives the first element.

    Which isn’t true. The 1-dimensional x is an array, it’s just that in some contexts an array decays into a pointer to its first element.

    Read the FAQ for everything you want to know about this subject.

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

Sidebar

Related Questions

Possible Duplicate: How to initialize a two-dimensional array in Python? I have always written
Possible Duplicate: Why java Arrays use two different sort algorithms for different types? So
Possible Duplicate: I have an array of integers, how do I use each one
Possible Duplicate: How to use include within a function? i have two file inc.php
Possible Duplicate: Array versus List<T>: When to use which? Is there any best practice
Possible Duplicate: Is array name a pointer in C? Array Type - Rules for
Possible Duplicate: How do I use arrays in C++? I have no idea how
Possible Duplicate: How do I use arrays in C++? I am not sure if
Possible Duplicate: Dynamic array in Stack? How do compilers treat variable length arrays Someone
Possible Duplicate: Python List vs. Array - when to use? I'm working on a

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.