arrays...

Chris Torek chris at mimsy.UUCP
Tue May 3 14:14:42 AEST 1988


In article <5773 at sigi.Colorado.EDU> swarbric at tramp.Colorado.EDU
(Frank Swarbrick) writes:
-Is there some reason why you can do:
-
-void foo(const int *bar);
-main() {
-   int ary[] = {1,2,3,4};
-   foo(ary);
-}

(Pre-dpANS compilers will not even do this; `ary' must be `static' or
global.  The restriction on automatic aggregate initialisers has been
lifted in dpANS C.)

-but you can't do
-
-void foo(const int *bar);
-main() {
-   foo({1,2,3,4});
-}

Yes: there is no aggregate builder that builds an array of int.

-... This is even stranger concidering you *can* do
-
-main() {
-   char str[20];
-   strcpy(str,"This sucks!");
-}
- strcpy(str,{'T','h','i','s',' ','s','u','c','k','s','\0'});
-doesn't work....

... but there *is* an aggregate builder that builds an array of
char, namely "".  Some of us feel that this is a flaw in the language,
that the only way to get most kinds of aggregates is to provide
names for them.

(Of course, if you add unnamed aggregates, you should also add
unnamed functions.)
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.lang.c mailing list