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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:16:52+00:00 2026-05-24T07:16:52+00:00

I think that it is because the former is an array of pointers to

  • 0

I think that it is because the former is an array of pointers to char and the latter is a pointer to an array of chars, and we need to properly specify the size of the object being pointed to for our function definition. In the former;

function(char * p_array[])

the size of the object being pointed to is already included (its a pointer to char), but the latter

function(char (*p_array)[])

needs the size of the array p_array points to as part of p_array’s definition?
I’m at the stage where I’ve been thinking about this for too long and have just confused myself, someone please let me know if my reasoning is correct.

  • 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-24T07:16:53+00:00Added an answer on May 24, 2026 at 7:16 am

    Both are valid in C but not C++. You would ordinarily be correct:

    char *x[]; // array of pointers to char
    char (*y)[]; // pointer to array of char
    

    However, the arrays decay to pointers if they appear as function parameters. So they become:

    char **x; // Changes to pointer to array of pointer to char
    char (*y)[]; // No decay, since it's NOT an array, it's a pointer to an array
    

    In an array type in C, one of the sizes is permitted to be unspecified. This must be the leftmost one (whoops, I said rightmost at first). So,

    int valid_array[][5]; // Ok
    int invalid_array[5][]; // Wrong
    

    (You can chain them… but we seldom have reason to do so…)

    int (*convoluted_array[][5])[][10];
    

    There is a catch, and the catch is that an array type with [] in it is an incomplete type. You can pass around a pointer to an incomplete type but certain operations will not work, as they need a complete type. For example, this will not work:

    void func(int (*x)[])
    {
        x[2][5] = 900; // Error
    }
    

    This is an error because in order to find the address of x[2], the compiler needs to know how big x[0] and x[1] are. But x[0] and x[1] have type int [] — an incomplete type with no information about how big it is. This becomes clearer if you imagine what the “un-decayed” version of the type would be, which is int x[][] — obviously invalid C. If you want to pass a two-dimensional array around in C, you have a few options:

    • Pass a one-dimensional array with a size parameter.

      void func(int n, int x[])
      {
          x[2*n + 5] = 900;
      }
      
    • Use an array of pointers to rows. This is somewhat clunky if you have genuine 2D data.

      void func(int *x[])
      {
          x[2][5] = 900;
      }
      
    • Use a fixed size.

      void func(int x[][5])
      {
          x[2][5] = 900;
      }
      
    • Use a variable length array (C99 only, so it probably doesn’t work with Microsoft compilers).

      // There's some funny syntax if you want 'x' before 'width'
      void func(int n, int x[][n])
      {
          x[2][5] = 900;
      }
      

    This is a frequent problem area even for C veterans. Many languages lack intrinsic “out-of-the-box” support for real, variable size, multidimensional arrays (C++, Java, Python) although a few languages do have it (Common Lisp, Haskell, Fortran). You’ll see a lot of code that uses arrays of arrays or that calculates array offsets manually.

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

Sidebar

Related Questions

I think I'm getting senile because I was convinced that to give a name
I have to ask this, because: The only thing I recognize is, that if
I think that java executables (jar files) are trivial to decompile and get the
I think that business logic should exist in a model when using an MVC
I think that it used to the be the case that in Liferay 4,
just think that when I opened my file then when I want to write
I think that this problem can be sorted using reflection (a technology which I'm
I think that Visual Studio's biggest let down is the Javascript editor. I have
I think that the zipper is a beautiful idea; it elegantly provides a way
Do you think that writing about software (i.e. having a blog) and speaking on

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.