Re: incrementing a pointer to an array
- From: Richard Heathfield <rjh@xxxxxxxxxxxxxxx>
- Date: Sat, 30 Aug 2008 06:51:23 +0000
subramanian100in@xxxxxxxxx, India said:
The following portion is from c-faq.com - comp.lang.c FAQ list ·
Question 6.13
int a1[3] = {0, 1, 2};
int a2[2][3] = {{3, 4, 5}, {6, 7, 8}};
int *ip; /* pointer to int */
int (*ap)[3]; /* pointer to array [3] of int */\
ap = &a1;
printf("%d\n", **ap);
ap++; /* WRONG */
Here why is incrementing ap ie 'ap++' mentioned as WRONG ?
I'm not sure. I don't know of any reason why it's illegal. Maybe Steve just
means it's a lousy idea.
Isn't it
similar to
int i_int = 100;
int *p = &i_int;
p++;
Yes.
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
.
- References:
- incrementing a pointer to an array
- From: subramanian100in@xxxxxxxxx, India
- incrementing a pointer to an array
- Prev by Date: incrementing a pointer to an array
- Next by Date: Re: incrementing a pointer to an array
- Previous by thread: incrementing a pointer to an array
- Next by thread: Re: incrementing a pointer to an array
- Index(es):
Relevant Pages
|