Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wasatch!cs.utexas.edu!uunet!mcsun!unido!rwthinf!ruso!wolfgang From: wolfgang@ruso.UUCP (Wolfgang Deifel) Newsgroups: comp.lang.c Subject: Re: swap(x,y) Message-ID: <1005@ruso.UUCP> Date: 28 Aug 89 08:32:04 GMT References: <1061@virtech.UUCP> <17504@ut-emx.UUCP> Organization: Dr. Ruff Software GmbH, Aachen, W.Germany Lines: 27 pmaniac@walt.cc.utexas.edu (Noah Friedman) writes: >void swap(double *x, double *y) >{ > *x += *y; > *y = *x - *y; > *x -= *y; >} >func() >{ > int a, b; > ... > swap((double *) &a, (double *) &b); > ... >} I think, this function never works right. If you cast the adress of an integer to adress of double, you don't cast the int to double. What you wanted to do is ( I think ), &((double)a) but this also doesn't work, because (double)a is an r-value which has no adress. -- Wolfgang Deifel Dr. Ruff Software GmbH, 5100 Aachen, Juelicherstr. 65-67, W-Germany uucp: ...!uunet{!mcvax}!unido!rwthinf!ruso!wolfgang - phone : +49 241 156038