type *var -- vs. -- type* var

Chris Torek chris at mimsy.UUCP
Sat Sep 9 14:09:32 AEST 1989


In article <29048 at news.Think.COM> barmar at think.COM (Barry Margolin) writes:
>They are equivalent.  The "*" is a separate token, and whitespace
>between tokens is not significant.

Right.

>>	int* x, y, z;
>>is equivalent to
>>	int *x, y, z;

(which is why I, for one, will not use the former layout).

>That's because "*" binds more tightly than ",".  If you want to force
>a particular grouping, use parentheses:
>
>	(int *) x, y, z

Nice idea, but you had better go read a C BNF.  Parentheses are not
permitted there.  You can, however, use typedef:

	typedef int *pointer_to_int;

	pointer_to_int x, y, z;
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.lang.c mailing list