Re: Pointer conversions
- From: Barry Schwarz <schwarzb@xxxxxxxxx>
- Date: Sun, 13 Jan 2008 09:36:57 -0800
On Wed, 09 Jan 2008 14:54:46 +0200, Ioannis Vranos <john@xxxxxxx>
wrote:
CBFalconer wrote:
Ioannis Vranos wrote:
Correction:
*(array_2d[0]) is array_2d[0][0].array_2d[0] is an array of 5 ints.array2d[0] is an array of 5 ints and it "behaves" (I do not know
the accurate technical term)as a pointer to array_2d[0][0], that is
No. Don't drop the details. *(array_2d[0]) is a pointer to an
array of 5 ints. array_2d[0][0] is an int. Just one.
Actually my correction with addition of parentheses was not needed.
Given: int array_2d[10][5];
array_2d behaves like a pointer to an array of 5 ints.
array2d_[0] behaves like a pointer to array_2d[0][0];
Why the inconsistency in your description - one with a type and one
with an object?
The rule is very straight forward: "Except when it is the operand of
the sizeof operator or the unary & operator, or is a string literal
used to initialize an array, an expression that has type ??array of
type?? is converted to an expression with type ??pointer to type??
that points to the initial element of the array object..."
The expression
array_2d
is converted to a pointer to array_2d[0] which has type pointer to
array of 5 int and which is expressed syntactically as
&array_2d[0]
which has type
int (*)[5]
The expression
array_2d[0]
is converted to a pointer to array_2d[0][0] which has type pointer to
int and which is expressed syntactically as
&array_2d[0][0]
which has type
int *
Remove del for email
.
- Follow-Ups:
- Re: Pointer conversions
- From: Ioannis Vranos
- Re: Pointer conversions
- References:
- Pointer conversions
- From: Ioannis Vranos
- Re: Pointer conversions
- From: Army1987
- Re: Pointer conversions
- From: cr88192
- Re: Pointer conversions
- From: Pierre Asselin
- Re: Pointer conversions
- From: cr88192
- Re: Pointer conversions
- From: Keith Thompson
- Re: Pointer conversions
- From: Pierre Asselin
- Re: Pointer conversions
- From: CBFalconer
- Re: Pointer conversions
- From: Ioannis Vranos
- Re: Pointer conversions
- From: Ioannis Vranos
- Re: Pointer conversions
- From: CBFalconer
- Re: Pointer conversions
- From: Ioannis Vranos
- Pointer conversions
- Prev by Date: Re: question
- Next by Date: Re: Preprocessor directive
- Previous by thread: Re: Pointer conversions
- Next by thread: Re: Pointer conversions
- Index(es):
Relevant Pages
|