Path: utzoo!utgpu!water!watmath!clyde!bellcore!tness7!tness1!sugar!ficc!peter@ficc.UUCP From: peter@ficc.UUCP (Peter da Silva) Newsgroups: comp.lang.c Subject: Re: arrays... Summary: Function Prototyping to the rescue! It's just an extension of "what type is this argument?". Message-ID: <790@.UUCP> Date: 18 May 88 14:59:25 GMT References: <5773@sigi.Colorado.EDU> <274@sdrc.UUCP> Sender: peter@ficc.UUCP Lines: 27 In article <274@sdrc.UUCP>, scjones@sdrc.UUCP (Larry Jones) writes: > In article ... swarbric@tramp.Colorado.EDU (Frank Swarbrick) writes: > > Is there some reason why you can do: > > int ary[] = {1,2,3,4}; > > foo(ary); > > but you can't do > > foo({1,2,3,4}); > Yep, there's quite a good reason -- just what is {1,2,3,4} supposed to be? Depends on how foo was declared: void foo(int *a); It's an array of ints. void foo(char *a); It's an array of chars. void foo(double *a); It's an array of doubles. struct x { int i; char c; float f; double d; }; void foo(struct x *a); It's a pointer to an int, a char, a float, and a double. This one's kinky: void foo(struct x a); Extra credit question: how does that differ from: void foo(int i, char c, float f, double d); And called with foo(1, 2, 3, 4);