Change representation of dynamic arrays?
Anders F Björklund
afb at algonet.se
Sat Oct 20 00:17:49 PDT 2007
Walter Bright wrote:
> What does this break?
>
> 1) Passing dynamic arrays to printf as in:
>
> printf("my string is %*.s\n", str);
I think you meant to write printf("my string is %.*s\n", str);
Which is something of an argument against printf in itself :-)
> which relied on the under-the-hood representation. This doesn't work on
> some architectures anyway, and is thoroughly obsolete. One could quickly
> fix such code by writing it as:
>
> printf("my string is %*.s\n", str.length, str.ptr);
Yes, but that change had to be done sooner or later anyway...
Same as with the cast from char[] to ulong, dirty hacks both.
> So, what do you think?
Good riddance.
--anders
More information about the Digitalmars-d
mailing list