Obscure C code (was Re: Excessive optimization)

Eric Smith eric at brouhaha.com
Thu Dec 2 17:50:16 CST 2010

Charles Dickman wrote:
 > Shouldn't it be (i + sizeof(int)*"He...\n") ?

No.  There shouldn't be a multiplication by sizeof(anything), because C 
does the scaling automatically, but the automatic scaling has to be of 
the size of the target of the pointer, which is char, not by the size of 
the index.  The automatic scaling is such that indices 0, 1, 2, etc. 
always refer to successive elements of the target type, and not to 
successive bytes.


More information about the cctech mailing list