C declarations

Howard Johnson howard at cyb-eng.UUCP
Tue Feb 12 06:58:51 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.

I wonder who came up with the idea that
	int foo[];
declares a pointer VARIABLE!?  True, foo[n] is EVALUATED as *(foo+n), but
I've never understood that this behavior should be extended to declarations.
Now I can live with foo[] being called a pointer CONSTANT, but not a
pointer variable--at least that's how array declarations are treated by
the C compilers I use.

>    int foobung[3] = {13, 42, 93}, Ack[] = {7, 6}, ichabod[] = foobung;

I hope the declaration
	int ichabod[] = foobung;
produces an error on your compiler, since this can be described as:
	int *ichabod = foobung;
-- 
	Howard Johnson		Cyb Systems, Austin, TX
..!{gatech,harvard,ihnp4,nbires,noao,seismo}!ut-sally!cyb-eng!howard



More information about the Comp.lang.c mailing list