Change representation of dynamic arrays?
Anders F Björklund
afb at algonet.se
Sat Oct 20 00:33:02 PDT 2007
Walter Bright wrote:
>>> 1) Passing dynamic arrays to printf as in:
>>> printf("my string is %*.s\n", str);
>>
>> Hmmm, currently I use printf("foo %s\n",std.string.toStringz(bar))
>> anyway, never tried what you're doing there. Did I miss something?
>
> printf("my string is %*.s\n", str.length, str.ptr);
>
> will be a little faster, because it doesn't need to allocate memory.
When I try this in C, it gives a warning about the "length" argument:
field precision should have type 'int', but argument 2 has type 'size_t'
Wouldn't this warning apply to C too, when using the printf function ?
I'm thinking it might need a cast(int) to work properly on 64-bit... ?
--anders
More information about the Digitalmars-d
mailing list