structure constant assignment

Supoj Sutanthavibul paul at cs.utexas.edu
Thu Oct 5 20:08:27 AEST 1989


We can always assign one structure variable to another
of the same type (at least on the SUN).  We can also
assign value to individual members of a structure but
it is so cumbersome especially in for large structures.
Initialization of structure variables is allowed.
However assignment of constant to a structure variable
in single assignment expression is not allowed (since
C syntax does nota allow construction of structure constants)

Why?

Does standard C allow assignment of structure constant as
in the following example?
I know that one can write functions to construct structure
constant but I think that is an overkill.

typedef		struct coord {
			int	x, y;
			}
		Coord;

main()
{
	Coord	p, q;

	q = (Coord){ 0, 0 };	<--- this is not allowed
	p = q;			<--- this is allowed.
	}



More information about the Comp.lang.c mailing list