arrays...

Peter da Silva peter at ficc.UUCP
Thu May 19 00:59:25 AEST 1988


In article <274 at sdrc.UUCP>, scjones at sdrc.UUCP (Larry Jones) writes:
> In article ... swarbric at 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);



More information about the Comp.lang.c mailing list