passing *char parameters by reference

Karl Heuer karl at haddock.ima.isc.com
Sat Aug 12 05:09:00 AEST 1989


In article <750 at greens.UUCP> matthew at 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 at haddock.isc.com), The Walking Lint



More information about the Comp.lang.c mailing list