Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!umd5!purdue!gatech!bbn!rochester!srs!craig From: craig@srs.UUCP (Craig Schmackpfeffer) Newsgroups: comp.lang.c Subject: Re: arrays... Message-ID: <835@srs.UUCP> Date: 3 May 88 13:42:33 GMT References: <5773@sigi.Colorado.EDU> Reply-To: srs!craig@cs.rochester.edu (Craig Schmackpfeffer) Organization: S.R. Systems, Rochester NY Lines: 39 In article <5773@sigi.Colorado.EDU> swarbric@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); >} >but you can't do >void foo(const int *bar); >main() >{ > foo({1,2,3,4}); >} > Because {1,2,3,4} is not an array, but merely a convenient way of initializing an array. >main() >{ > char str[20]; > > strcpy(str,"This sucks!"); >} > >(no, > strcpy(str,{'T','h','i','s',' ','s','u','c','k','s','\0'}); >doesn't work....) > >Frank Swarbrick (and his cat) swarbric@tramp.Colorado.EDU A string of characters within double quotes is represented as the array of those characters followed by a terminating null byte. It is defined to return the address of the array. The second attempt at the {} usage doesn't work for the same reason the first try didn't work. -- Craig Schmackpfeffer @ S.R. Systems {allegra,rutgers,ames}!rochester!srs!craig