C declarations
Angus Greiswald the fourth
ag4 at pucc-h
Wed Jan 30 03:21:07 AEST 1985
> int ptr[]; declares one pointer
> but
> int ptr[] = { 1, 2, 3 }; declares a three element int array.
>
> Is this a desirable characteristic of C? Could someone please comment on
> the precise meaning of [] in declarations.
Well, I look at it this way: foo[] is an array whose location and/or size is
variable and thus needs to be declared as a pointer, and biff[4] is a fixed
size array whose location is constant, and thus biff can be declared as
a constant. When there is an initializer, you can explicitly declare the
size of an array, leave the compiler to count for itself, or specify
it to be non-fixed in size and position with an initial value.
int foobung[3] = {13, 42, 93}, Ack[] = {7, 6}, ichabod[] = foobung;
Of course, int *foo is a different matter. Hope I covered what you
were interested in.
--
Jeff Lewis vvvvvvvvvvvv
{decvax|ucbvax|allegra|seismo|harpo|teklabs|ihnp4}!pur-ee!lewie
^^^^^^^^^^^^
More information about the Comp.lang.c
mailing list