Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!unido!fauern!tumuc!guug!pcsbst! From: roland@cochise.pcs.com (Roland Rambau) Newsgroups: comp.lang.c Subject: Re: assigning a structure (what is happening?) Message-ID: <1990May7.091526.18954@pcsbst.pcs.com> Date: 7 May 90 09:15:26 GMT References: <21734@dartvax.Dartmouth.EDU> Sender: @pcsbst.pcs.com Organization: PCS Computer Systeme GmbH Lines: 29 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. */ Yes, its legal ( with ANSI ). Its a structure assignment, will copy sizeof( struct inv ) bytes of memory ( 6 byte or 8 byte or whatever the implementor may need for alignment ) -> return(s2); /* it seems to work okay. How do the members get */ -> /* their assignment? Do pointers come to play here? */ Also legal. There are several quite different techniques to implement this; but since s2 is an auto object, this return statement will probably imply another 6-8 byte copy im memory. ->} Roland Rambau rra@cochise.pcs.com, {unido|pyramid}!pcsbst!rra, 2:507/414.2.fidonet