Path: utzoo!censor!geac!jtsv16!uunet!virtech!cpcahil
From: cpcahil@virtech.UUCP (Conor P. Cahill)
Newsgroups: comp.lang.c
Subject: Re: passing *char parameters by reference
Message-ID: <993@virtech.UUCP>
Date: 10 Aug 89 02:02:35 GMT
References: <1424@novavax.UUCP>
Distribution: usa
Organization: Virtual Technologies Inc
Lines: 38

In article <1424@novavax.UUCP>, gls@novavax.UUCP (Gary Schaps) writes:

I assume there is a line here that says:
  swap(x,y)
> char *x, *y;
> {
>    register char *temp;
> 
>    temp = x;
>    x = y;
>    y = temp;
> }
> 
> main()
> {
>    char *a="aaaa";
>    char *b="bbbb";
> 
>    swap( &a, &b );
>    printf( " a = %s\t b = %s\n", a, b);
> }


1.  You are calling swap with the & (address of) a character pointer.
    This is a pointer to a pointer.  Therefore the swap function must
    be written as follows:

	void
	swap(x,y)
		char **x;
		char **y;
	{
		retister char *temp;
		temp = *x;
		*x = *y;
		*y = temp;
	}