assigning a structure (what is happening?)

Michael J. Eager eager at ringworld.Eng.Sun.COM
Thu May 3 14:17:05 AEST 1990


In article <21734 at dartvax.Dartmouth.EDU> pete at eleazar.dartmouth.edu (Pete Schmitt) writes:
>
>struct inv
>{
>	long number;
>	char name[2];
>}
>struct inv func(s)
>struct inv s;
>{
>	struct inv s2;
>
>	s2 = s;		/* is this legal?  If not why not. If so why so. */
>    	return(s2);	/* it seems to work okay. How do the members get */
>			/* their assignment?  Do pointers come to play here? */
>}
>--
>     Peter Schmitt					UNIX/VMS Consultant
>Kiewit Computation Center				   User Services
>   Dartmouth College					   (603)646-2085
>   Hanover, NH 03755				    Peter.Schmitt at Dartmouth.EDU


The ANSI standard gives "full faith and credit" to structured variables.
They can be assigned, passed to functions and returned from functions exactly
as a simple variable.  Assignment (and by extension argument passing and 
returning) is on a bit-copy basis.  No pointers need be used.

Returning values is a bit sticky to implement, especially with recursive
routines.

-- Mike Eager



More information about the Comp.lang.c mailing list