sscanf() compile errors (changed since dmd v0.118)?
AEon
aeon2001 at lycos.de
Thu Sep 18 05:26:19 PDT 2008
Continuing to compile my 3.5 year old D code, the compiler yields this
error:
dmd -c -w -version=db_log -I. aepar_p_q3a.d
aepar_p_q3a.d(189): function std.c.stdio.sscanf (char*,char*,...)
does not match parameter types
(char[],char[],int*,int*)
aepar_p_q3a.d(189): Error: cannot implicitly convert expression (line)
of type char[] to char*
aepar_p_q3a.d(189): Error: cannot implicitly convert expression (ttempl)
of type char[] to char*
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 want to keep using "char[] line" from my main function, so
what would be the clean way to avoid the compiler error?
Would casting be "good"? :
int ret = sscanf( cast(char*)line, cast(char*)ttempl, &min, &sec );
Works, no compiler error, but am I hacking something I should not?
Are there any "new" Phobos native commands that should
rather be used than the probably outdated sscanf() (from
std.c.stdio: sscanf() int sscanf(char*, char*,...); )).
Thanks
AEon
More information about the Digitalmars-d-learn
mailing list