Ternary Operator: (cond ? const_str : nonconst_str) legal?

diamond@tkovoa diamond at tkou02.enet.dec.com
Mon Jun 4 16:04:45 AEST 1990


In article <000019B at cdis-1.compu.com> tanner at cdis-1.compu.com writes:

>	char		nonconst_str[10];
>	const char	const_str[10] = "123456789";
>	blunge = printf("%s\n", cond ? const_str : nonconst_str);

It is legal.  The expression (cond ? const_str : nonconst_str) has
type (const char *).

-- 
Norman Diamond, Nihon DEC     diamond at tkou02.enet.dec.com
Proposed group comp.networks.load-reduction:  send your "yes" vote to /dev/null.



More information about the Comp.lang.c mailing list