Path: utzoo!news-server.csri.toronto.edu!rutgers!news.cs.indiana.edu!spool.mu.edu!uunet!tdatirv!sarima From: sarima@tdatirv.UUCP (Stanley Friesen) Newsgroups: comp.lang.c Subject: Re: A quick question... Message-ID: <170@tdatirv.UUCP> Date: 12 Mar 91 17:37:47 GMT References: <1991Mar12.030759.26698@nntp-server.caltech.edu> Reply-To: sarima@tdatirv.UUCP (Stanley Friesen) Organization: Teradata Corp., Irvine Lines: 24 In article <1991Mar12.030759.26698@nntp-server.caltech.edu> eychaner@suncub.bbso.caltech.edu writes: >Just a quick question...I personally still don't quite understand what is >and is not legal on the left side of an assignment. >Is this legal... > unsigned char *pointer1; > short short_value; > ... > *((short *) pointer1) = short_value; > ... >And does it do what I think it does, that is, assign short_value to the >storage pointed to by pointer1? I hope you understand what I mean... Assuming that you have initialized pointer1 to point to a suitably alligned block of memory at least large enough to hold one short, then yes. If the pointer1 is uninitialized, or points to an improperly alligned block, or points to a block that is too small then the result is undefined. To put it another way: Dereferencing a pointer always yields an lvalue if the pointer is valid. If the pointer is invalid, the dereference yields undefined results. -- --------------- uunet!tdatirv!sarima (Stanley Friesen)