Doctor C's Pointers
Stephen Clamage
steve at taumet.com
Fri Aug 3 02:15:30 AEST 1990
nickh at wotk.UUCP (Nick Hennenfent) writes:
>( "abcd"[i] and f()[j] )
> ^^^^^
>I thought this was taboo. What's the story on this?
In ANSI C, it's perfectly ok, as long as f() is declared to return a
pointer type. Many earlier C compilers did not support this, however,
and its portability was not guaranteed. Any conforming ANSI compiler
must allow it.
Similarly, if f() returns a struct type with member x, you could write
f().x, and if f() returns a pointer to a function, you could write f()().
I make no comment on whether any of this is good programming practice.
--
Steve Clamage, TauMetric Corp, steve at taumet.com
More information about the Comp.lang.c
mailing list