rokicki@navajo.STANFORD.EDU (Tomas Rokicki) (08/19/86)
[ Snugglebunnies, snugglebunnies, snuggl+~=/ In a program I have been writing, I have found it nice to have immediate character arrays, so I could do things like cmdchr = "rofq"[menu_selection] ; Is this legal and portable? It seems to work. -tom
guy@sun.UUCP (08/19/86)
> 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@sun.com (or guy@sun.arpa)
ark@alice.UucP (Andrew Koenig) (08/20/86)
> In a program I have been writing, I have found it nice to > have immediate character arrays, so I could do things like > > cmdchr = "rofq"[menu_selection] ; > > Is this legal and portable? It seems to work. -tom Yes.
gwyn@BRL.ARPA (VLD/VMB) (08/21/86)
Yes, "string"[index] is legal, portable, etc.