Using strings as immediate character arrays

guy at sun.UUCP guy at sun.UUCP
Tue Aug 19 16:25:58 AEST 1986


> 	cmdchr = "rofq"[menu_selection] ;
> 
> Is this legal and portable?  It seems to work.      -tom

It is perfectly legal, and therefore portable to all C implementations.
There may, however, be programs that purport to be C compilers that don't
implement it, although I don't know of any.

(The real test, of course, is whether

	cmdchr = menu_selection["rofq"];

yields the same result.  Any compiler that doesn't produce object code that
yields the same result isn't a C compiler.)
-- 
	Guy Harris
	{ihnp4, decvax, seismo, decwrl, ...}!sun!guy
	guy at sun.com (or guy at sun.arpa)



More information about the Comp.lang.c mailing list