0
int (*ptr)[10];

I know what int *ptr[10]; its a 10 member array where each element is a pointer to an integer.

But what does the above piece code create ?

Aditya
  • 1,240
  • 2
  • 14
  • 38
  • 2
    People there're zillion dupes for this, marking this dupe is more prudent than answering for rep. – legends2k Jan 28 '14 at 08:34
  • BTW, parentheses modify precedence. Read the declarator precedence rules of C. Obviously, if `int *ptr[10]` is an array of pointers, then `int (*ptr)[10]` must be a pointer to array. –  Jan 28 '14 at 08:34
  • 2
    @legends2k Agreed, also please stop upvoting. –  Jan 28 '14 at 08:35
  • 1
    @H2CO3: Exactly, just because someone sees this for the first time, they upvote it, instead of knowing about (such old concepts) from searching or reading related material, thereby increasing the fake-value of dupes. – legends2k Jan 28 '14 at 08:37

2 Answers2

3
int *ptr[10]

is an array of 10 int pointers,

int (*ptr)[10]

is a pointer to an array of 10 ints

Ansh David
  • 654
  • 1
  • 10
  • 26
1

Cdecl (http://cdecl.ridiculousfish.com/?q=int+%28*p%29[10] ) says:

declare p as pointer to array 10 of int 

That is: ptr is a pointer to an array, which is rarely useful. See http://c-faq.com/aryptr/ptrtoarray.html

Magnus Reftel
  • 967
  • 6
  • 19