Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!network!sdcsvax!ucsdhub!hp-sdd!hplabs!hpl-opus!hpnmdla!hpmwtd!jeffa
From: jeffa@hpmwtd.HP.COM (Jeff Aguilera)
Newsgroups: comp.lang.c
Subject: Re: passing *char parameters by reference
Message-ID: <680005@hpmwjaa.HP.COM>
Date: 10 Aug 89 22:51:28 GMT
References: <1424@novavax.UUCP>
Organization: HP Microwave Tech. - Santa Rosa, Ca.
Lines: 22

>> Would someone be kind enough to tell me why this program fails?

Because it is wrong.  Instead try

swap(x,y)
	register char **x, **y;
{
	register char *temp;

	temp = (*x);	/* parentheses added for clarity */
	(*x) = (*y);
	(*y) = temp;
}

main()
{
	char *a="aaaa";
	char *b="bbbb";

	swap( &a, &b );	/* Note that &(char*) produces a (char**) */
	printf( " a = %s\t b = %s\n", a, b);
}