String to Double
-
Check your documentation on
sscanf
. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo -
strtod() --- CPUA 0x5041 Sonork 100.11743 Chicken Little It may be that your sole purpose in life is simply to serve as a warning to others.
-
double ConvertStringToDouble(const CString s) { char pszString[MAX_PATH]; char* pszStop; memset(pszString, '\0', MAX_PATH); strncpy(pszString, (LPCTSTR)s, s.GetLength()); double d = strtod((const char*)pszString, &pszStop, 0); return d; }
double ConvertStringToDouble (LPCTSTR psz)
{
LPTSTR pszStop;
errno = 0;//only if you might check this value
return _tcstod (psz, &pszStop);
}or (if you don't like the "T" variables)
double ConvertStringToDouble (const char *psz)
{
char *pszStop;
errno = 0;
return strtod (psz, &pszStop);
}Since CString has a type cast to LPCTSTR and since you won't be storing the value into another CString, then there isn't any need to use CString in the argument list. Tim Smith I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?