|
-
July 17th, 1999, 03:46 AM
#4
Re: atoi / atof - How to make a Number
Here is a function that does exactly what you asked:
double str2float(CString str)
{
CString strFloat = str;
CString strInt = "";
CString strZecim = "0";
BOOL bZecim = FALSE;
for(int c=0; c<strFloat.GetLength(); c++){
if(strFloat[c] == ',' && !bZecim){
bZecim = TRUE;
strZecim = "";
}
if(!bZecim){
if(strFloat[c] >= '0' && strFloat[c] <= '9')
strInt += strFloat[c];
}
else{
if(strFloat[c] >= '0' && strFloat[c] <= '9')
strZecim += strFloat[c];
}
}
strFloat = strInt + "." + strZecim;
return (double)atof(strFloat);
}
Regards,
Dani Zilcsak
mailto [email protected]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|