Thank you, David.
This is in fact the same that I wanted to explain with my much longer
post some hours earlier.
In fact, there is only one (or two) differences between
int *p;
and
int p[10];
that are:
in the first case, only a pointer is declared and no storage for an
array is allocated,
and in the second case there is an array allocated with 10 elements
(indexed from 0
to 9) in automatic storage (first difference)
and: in the first case, p (the address) can be changed, and in the
second case it
cannot be changed.
But:
after you do
p = malloc (sizeof (int) * 10);
you can use both p's in the same manner, the first difference has gone
away -
the second difference, of course, remains.
The compiler can immediately change every reference of the form
p[n]
to
*(p + n)
because it is always the same, no matter if p is a pointer or an array.
Much the same way as
(*p).s
for dereferecing a pointer to a structure and selecting a component
can always be written as
p -> s
That makes compiler builder's life easy.
Remember: C was a language for minicomputers like PDP-8 etc.,
that's its heritage.
Kind regards
Bernd
Am 01.07.2013 13:47, schrieb David Crayford:
void cfunc( int * array ) is equivalent to void cfunc( int array[] )
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN