Path: utzoo!attcan!uunet!mcsun!hp4nl!star.cs.vu.nl!condict From: condict@cs.vu.nl (Michael Condict) Newsgroups: comp.lang.c Subject: Re: Brain Teaser Keywords: { void * x, * y; x <-> y; } Message-ID: <6293@star.cs.vu.nl> Date: 12 Apr 90 14:15:37 GMT References: <10289@wpi.wpi.edu> <2039@awdprime.UUCP> Sender: news@cs.vu.nl Organization: Fac. Wiskunde & Informatica, VU, Amsterdam Lines: 31 In article <2039@awdprime.UUCP> cs.utexas.edu!ibmchs!auschs!sanders.austin.ibm.com!sanders (Tony Sanders) writes: |In article <10289@wpi.wpi.edu> oesterle@wpi.wpi.edu (Shawn H. Oesterle) writes: |-Example: |- { |- void * x, * y, * tmp; |- |- tmp = x; |- x = y; |- y = x; |- } |- Make a piece of code which has the same effect as this, but without |- using the 'tmp' variable (in C, of course). |This is really quite easy AND ANSI compliant. | |You see, to "make a piece of code which has the same effect" as your |sample code, this will suffice: | void *x, *y; | x = y; | |If you don't believe me then double check your sample code. Actually, the sample code can be optimized more than that. It is exactly equivalent to the following statement: ; since the variables are all local to the block. -- Michael Condict condict@cs.vu.nl Vrije University Amsterdam