A
Alessio
Hi,
I've written a function that convert a string into double using strtod.
Is right or there are some advice that I miss ?
Thank you.
double stringtofloat(const char *const szString, bool *const fError)
{
double dValue = 0.0;
char *p = NULL;
*fError = false;
if ( NULL == szString )
{
*fError = true;
return 0.0;
}
dValue = strtod(szString, &p);
if ( p && *p )
{
*fError = true;
return dValue;
}
return dValue;
}
I've written a function that convert a string into double using strtod.
Is right or there are some advice that I miss ?
Thank you.
double stringtofloat(const char *const szString, bool *const fError)
{
double dValue = 0.0;
char *p = NULL;
*fError = false;
if ( NULL == szString )
{
*fError = true;
return 0.0;
}
dValue = strtod(szString, &p);
if ( p && *p )
{
*fError = true;
return dValue;
}
return dValue;
}