Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!ico!ism780c!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: passing *char parameters by reference Message-ID: <14271@haddock.ima.isc.com> Date: 11 Aug 89 19:09:00 GMT References: <1424@novavax.UUCP> <750@greens.UUCP> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Distribution: usa Organization: Interactive Systems, Boston Lines: 19 In article <750@greens.UUCP> matthew@sunpix.UUCP ( Sun Visualization Products) writes: >(...I've taken the liberty of converting them to type 'void', since pointer >type is only important when doing mathimatical operations on the pointers >themselves.) Uh, that's not quite true. > void swap(x,y) void **x, **y; { > register void *temp; > temp = *x; *x = *y; *y = temp; > } This is a function that can be used to swap two |void *| objects. Because of a grandfather clause, it can also be used to swap two |char *| objects. It is *not* necessarily true that it can swap |int *|s, though; on some machines |char *| and |int *| have different representations, and there's no guarantee that they even have the same length. Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint