470,870 Members | 1,404 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,870 developers. It's quick & easy.

What is the difference between: int a (*daytab)[13] and int a*daytab[13]

thx
Jun 27 '08 #1
5 1811

int (*)[13] Pointer to an array of 13 int's.
int *[13] Array of 13 pointers to int's.
Jun 27 '08 #2

"magicman" <ir*********@gmail.comwrote in message
news:11**********************************@k13g2000 hse.googlegroups.com..

[What is the difference between: int a (*daytab)[13] and int a
*daytab[13]]

As written: nothing, they're both syntax errors.

On the other hand, int (*daytab)[13] is a pointer to an array of 13 ints.

While int *daytab[13] is an array of 13 pointers to ints.

(Thanks to a program cdecl.exe I've just downloaded. Otherwise I wouldn't
have a clue either. And the existence of such a program suggests I'm not
alone!)

--
Bartc
Jun 27 '08 #3
magicman wrote:
What is the difference between: int a (*daytab)[13] and int a
*daytab[13]
thx
In a declaration the first one declares daytab as a pointer to an array
of 13 ints. The second declares daytab as an array of 13 int*.

For the first one

daytab[n]

will be of type int and for the second one

daytab[n]

will be of type int*.

PS. For 0 <= n <= 12 of course.

Jun 27 '08 #4
santosh <sa*********@gmail.comwrites:
magicman wrote:
>What is the difference between: int a (*daytab)[13] and int a
*daytab[13]
thx

In a declaration the first one declares daytab as a pointer to an array
of 13 ints. The second declares daytab as an array of 13 int*.
I guess you are ignoring the "a" in both!
For the first one

daytab[n]

will be of type int
It will be of type "array of 13 int". It will be converted to an int
pointer in most contexts hence, I suspect, the confusion.
and for the second one

daytab[n]

will be of type int*.
Yes, in both cases daytab[n] could be further subscripted or passed to
function that expects and int *.

--
Ben.
Jun 27 '08 #5
Ben Bacarisse wrote:
santosh <sa*********@gmail.comwrites:
>magicman wrote:
>>What is the difference between: int a (*daytab)[13] and int a
*daytab[13]
thx

In a declaration the first one declares daytab as a pointer to an
array of 13 ints. The second declares daytab as an array of 13 int*.

I guess you are ignoring the "a" in both!
Oops! I'm starting to really believe the research indications that the
brain "reads" what it "wants to read", or "completes" sentences from
partially reading them. Thanks once again for the correction.
>For the first one

daytab[n]

will be of type int

It will be of type "array of 13 int". It will be converted to an int
pointer in most contexts hence, I suspect, the confusion.
>and for the second one

daytab[n]

will be of type int*.

Yes, in both cases daytab[n] could be further subscripted or passed to
function that expects and int *.
Jun 27 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

137 posts views Thread by Philippe C. Martin | last post: by
9 posts views Thread by Vipul Jain | last post: by
72 posts views Thread by E. Robert Tisdale | last post: by
5 posts views Thread by Kemal Ozan | last post: by
7 posts views Thread by Simon Peng | last post: by
19 posts views Thread by arnuld | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.