Re: strange call



Context:
f()[2] = 'x';

Malcolm said:

"Richard Heathfield" wrote...

It's a perfectly legal shorthand for:

int *p = f();
p[2] = 'x';

without going to all the trouble and inconvenience of defining a
temporary object p to store the pointer value returned by f.

At the cost of considerable trouble and inconvenience for Kavya, who has
the unhappy task of reading this code.

Yes. I'm not overly keen on it either, but occasionally I've been guilty of
the equivalent, *strchr(foo, bar) = baz, when I knew for sure that bar
appears in foo. Tsk tsk, as they say...

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: normal service will be restored as soon as possible. Please do not
adjust your email clients.
.



Relevant Pages