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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:33:17+00:00 2026-05-26T11:33:17+00:00

see i have seen some code like int (*b)[10]; which means declare b as

  • 0

see i have seen some code like

int (*b)[10];

which means

declare b as pointer to array 10 of int

so i want to ask you what is the purpose of doing this ?

why don’t we write instead of that just

int array[10];

and use as passing address of array.

both are same or any difference ?

Edit :
Dont be confuse with

int *b[10];  // this one declare b as array 10 of pointer to int

and

int (*b)[10];  // this one declare b as pointer to array 10 of int

one more Edit

see int (*b)[10];

1>will allocate memory for 10 elements of int and the address of that memory will be assigned to b ?

or

2>there will be no memory allocated for array. here it says b is capable of holding address of and int array of 10 element ?

which option is right ?
if any one is right then why one should use this complex syntax rather then using different method?

  • 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-26T11:33:17+00:00Added an answer on May 26, 2026 at 11:33 am

    There’s a difference actually. In int b[10], b is a pointer constant (which means it can be used to modify its underlying data but it can’t be changed to point to something else). The pointer in int (*b)[10] on the other hand can be changed to point to something else (as well as being able to change its underlying data of course). So the difference is that by saying that b is int (*b)[10]; you’re hereby warning the next developer who sees your code that this b can point to something else somewhere in the code. That’s why – obviously – don’t do that except if you really intend to change what b is pointing to (otherwise you’re just confusing who’ll come after you).

    Regarding your question, I checked using sizeof(b).

    int (*b)[10] ==> sizeof(b) is 4 (which means no memory allocated – Option 2).

    int b[10] ==> sizeof(b) is 40 (which means memory is allocated as expected – Option 1).

    Look at this:

    int (*b)[10];
    
    int x[10];
    b = &x;
    

    This compiled. Change the size of the array to anything else. It’ll not compile! This means that you’re extremely correct :-D. Option 2 is written perfectly: This pointer can only point to an array of size 10 and nothing else.

    [Added as per request of question owner]

    What’s the advantage of such a syntax? It’s just a feature that’s already there, and maybe it’s useful for somebody. This is how I understand it (and please correct me if wrong): For example, you can say: string (*names_of_players_in_soccer_team)[11]; and the advantage is – obviously – restricting the array to be exactly 11 names to handle the application logic – the team must actually have exactly 11 names. This gives more readability for those who’ll read your code, and emphasizes its correctness…

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

Sidebar

Related Questions

I have seen the official demos on lwjgl.org but I would like to see
I have see code like this Dim s as something = new something Dim
I have some code that I want to build. The code uses boost::ptr_map class
I have just seen this // Check to see if the request is a
(resolved: see bottom) I have the following code snippet: Protected Sub SqlDataSource1_Inserted(ByVal sender As
I see an application have used Log.info = some info where are these logs
I have seen quite a few code samples/plugins that promote uploading assets directly to
I have some inherited code that I am modifying. However, I am seeing something
I have been doing some reading, and I see that I can use getch()
I have seen there are many JSON parsers in Java. Some target speed, some

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.