assigning a structure (what is happening?)
Julian Anigbogu
anigbogu at loria.crin.fr
Mon Apr 30 19:23:12 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) , 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? */
>}
Assigning s to s2 is perfectly legal C so you shouldn't be surprised
that returning s2 does exactly what you want. The members get their
correct values because this is done in a one-to-one correspondence.
That is why, the necessary condition is that both source and
destination have to be of the same type.
Julian
------
---------------------------------------
e-mail: anigbogu at loria.crin.fr | All opinions expressed here are |
| naturally mine. However ... |
----------------------------------------
--
---------------------------------------
e-mail: anigbogu at loria.crin.fr | All opinions expressed here are |
| naturally mine. However ... |
----------------------------------------
More information about the Comp.lang.c
mailing list