sscanf() compile errors (changed since dmd v0.118)?
AEon
aeon2001 at lycos.de
Thu Sep 18 05:54:58 PDT 2008
Lars Kyllingstad wrote:
>> aepar_p_q3a.d:
>> ---snip---
>> int rip_Time_in_Seconds( char[] line )
>> {
>> char[] ttempl = "%d:%d"; // Time Template
>> int min, sec;
>>
>> int ret = sscanf( line, ttempl, &min, &sec ); // Line 189
>> int uptime = min * 60 + sec;
>>
>> return uptime;
>> }
>> ---snip---
> I don't know whether such casting is considered bad practice. Anyway,
> you should use the 'ptr' property of arrays instead, as it's cleaner.
>
> int ret = sscanf( line.ptr, ttempl.ptr, &min, &sec );
>
> Check out http://www.digitalmars.com/d/1.0/arrays.html and look for
> "Dynamic Array Properties". You'll find it there.
Ah... yes that looks a lot less like a "hack". Works fine.
More information about the Digitalmars-d-learn
mailing list