[farther OT] Re: Why Is Escaping Data Considered So Magical?

Michael Torrie torriem at gmail.com
Thu Jul 1 12:10:16 EDT 2010


On 07/01/2010 01:24 AM, Nobody wrote:
> No, the type of "buf" is "char [512]", i.e. "array of 512 chars". If you
> use "buf" as an rvalue (rather than an lvalue), it will be implicitly
> converted to char*.

Yes this is true.  I misstated.  I meant that most text books I've seen
say to just use the variable in an *rvalue* as a pointer (can't think of
any lvalue use of an array).

K&R states that arrays (in C anyway) are always *passed* by pointer,
hence when you pass an array to a function it automatically decays into
a pointer.  Which is what you said.  So no need for & and the compiler
warning you get with it.  That's all.

If the OP was striving for pedantic correctness, he would use &buf[0].



More information about the Python-list mailing list