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

Barry Margolin barmar at think.COM
Sat Sep 9 04:38:21 AEST 1989


In article <4201 at ohstpy.mps.ohio-state.edu> SMITHJ at ohstpy.mps.ohio-state.edu writes:
>	type* var;
>rather than
>	type *var;

They are equivalent.  The "*" is a separate token, and whitespace
between tokens is not significant.

>	int* x, y, z;
>is equivalent to
>	int *x, y, z;
>rather than
>	int *x, *y, *z;
>as would be intuitive (to me anyway).

That's because "*" binds more tightly than ",".  If you want to force
a particular grouping, use parentheses:

	(int *) x, y, z

Barry Margolin
Thinking Machines Corp.

barmar at think.com
{uunet,harvard}!think!barmar



More information about the Comp.lang.c mailing list