Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!uwm.edu!rpi!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!ames!amdcad.amd.com!sun!ringworld.Eng.Sun.COM!eager From: eager@ringworld.Eng.Sun.COM (Michael J. Eager) Newsgroups: comp.lang.c Subject: Re: assigning a structure (what is happening?) Message-ID: <135151@sun.Eng.Sun.COM> Date: 3 May 90 04:17:05 GMT References: <21734@dartvax.Dartmouth.EDU> Sender: news@sun.Eng.Sun.COM Organization: Sun Microsystems, Mt. View, Ca. Lines: 32 In article <21734@dartvax.Dartmouth.EDU> pete@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@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