peter_b
asked on
Beginner: conversions
cannot convert a string to a float.
CString name, val;
for (int iii = 0; iii < 15; iii++)
{
name.Format("windspp %d",iii);
val = app->GetProfileString("pro file",name , "");
ppdata[iii] = "%f", val
}
ppdata is an array of floats.
the registry entry that is read is a number 12,67 for example but i can only get it out as a string if i am right (?).
Now how do I convert a string to a float ??
could someone copy/paste a list of possible conversions here as i allways fall across one i cannot do.
thanks for helping.
CString name, val;
for (int iii = 0; iii < 15; iii++)
{
name.Format("windspp %d",iii);
val = app->GetProfileString("pro
ppdata[iii] = "%f", val
}
ppdata is an array of floats.
the registry entry that is read is a number 12,67 for example but i can only get it out as a string if i am right (?).
Now how do I convert a string to a float ??
could someone copy/paste a list of possible conversions here as i allways fall across one i cannot do.
thanks for helping.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
well theres a loss of data from double to float but should be ok.
Can you gie me some other conversion possibilities I am allways hanging with this ?
Can you gie me some other conversion possibilities I am allways hanging with this ?
atof should return a double so you shouldn't see any loss of data if you make your array an array of double.
There is also the strtod function
char *stringstop;
ppdata[iii] = strtod(val,&stringstop);
There is also the strtod function
char *stringstop;
ppdata[iii] = strtod(val,&stringstop);
ASKER
okok great thanks but is there a list of all functions i can use somewhere ? the MS help is awfull...
If you have MSDN go to the index tab and type 'data conversion routines' or
'string manipulation routines' for a full list of functions that should be of interest to you.
If you don't have MSDN go to
http://msdn.microsoft.com/library/devprods/vs6/visualc/vccore/_crt_data_conversion.htm
'string manipulation routines' for a full list of functions that should be of interest to you.
If you don't have MSDN go to
http://msdn.microsoft.com/library/devprods/vs6/visualc/vccore/_crt_data_conversion.htm
ASKER
thanks you helped me alot !!
ASKER
this line is an error of course but thats what i would like to do...