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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:09:56+00:00 2026-05-25T21:09:56+00:00

There is such code: int tab[14][2]; int (*wskk)[2] = tab; // &tab makes error

  • 0

There is such code:

int tab[14][2];
int (*wskk)[2] = tab; // &tab makes error

int tab2[2];
wskk = &tab2; // tab2 makes error

Why is it possible to use one pointer to point at two arrays of different dimensions?

  • 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-25T21:09:56+00:00Added an answer on May 25, 2026 at 9:09 pm

    To understand what’s going on you must be familiar with a few key-concepts:

    • a multidimensional array is an array of arrays;
    • the name of an array decays to a pointer to its first element;
    • the type of wskk is “pointer to an array of 2 ints”.

    Thus, if you write tab you’re getting a pointer to the first element of tab, which is its first row; the row has type int[2], so a pointer to it has type int (*)[2], which is exactly the type of your pointer. Because of this you can assign tab to wskk, which will now point to the first row of tab.

    You can’t assign &tab to it, because that yields you a pointer to the whole multidimensional array, which is of type int (*)[14][2].

    As for the second piece, it’s even simpler: tab2 is an array of two ints, so its type is int[2]. If you get a pointer to it via the & operator, you get a int (*)[2], which is the type of your pointer. Actually, it makes sense: tab2 and a row of tab are effectively the same stuff (an array of 2 ints).

    You can’t assign tab2 to it because tab2 decays to a pointer to its first element, i.e. an int *.

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

Sidebar

Related Questions

i use such code, but it renders with error <li class=dd0><div id=dt1<a href=http://localhost:1675/Category/29-books.aspx>Books</a></div></li> there
There is such code: #include <iostream> int main() { int size; std::cin >> size;
There is such code: int (*ptr_)[1] = new int[1][1]; ptr_[0][0] = 100; std::cout <<
There is such code: int fun1(){ return 2 + 3; } inline int fun2(){
There is such code: const int fun(){ return 2; } // can be assigned
There is such code: #include <iostream> int main() { int a; int* p =
There is such code: #include <iostream> int main(){ unsigned int* wsk2 = new unsigned
There is such code: #include <iostream> int main(){ const int a = 2; int*
There is such code: #include <cstdlib> #include <clang-c/Index.h> using namespace std; int main(int argc,
There is such code: #include <iostream> class A{ int a; int fun(){} }; class

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.