pointers to arrays

Chris Torek chris at mimsy.UUCP
Mon Feb 20 08:56:43 AEST 1989


>>	int (*foo)[13];
>>	int bar[13];
>>
>>	foo = &bar;

In article <19797 at uflorida.cis.ufl.EDU> thoth at beach.cis.ufl.edu
(Robert Forsman) writes:
>AUUUGH!  what happens if you say (*foo) = muck (where muck is int muck[13])

You get an error, just as if you had said

	bar = muck;

The left hand side of an assignment operator is an lvalue context, and
an array designator (such as bar or *foo) in an lvalue context is an
error.  (The other option for the language designer is to say that if
an array designator appears on the lhs of an assignment, the rhs must
be conformable, and the elements of the arrays are copied.  But C will
not do that for you.)
-- 
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