![]() |
convert char array to double
How can i convert char array to double ,i tried to typecast it but it gave error.
Code:
char tmp[12]=dfdfsdfsd;Code:
errorC2440 typecast' : cannot convert from 'char[12]' to 'double' |
Re: convert char array to double
You can not convert the full string to a double .Because when you convert you need just a single value .
Consider the code, Code:
#include <stdio.h> |
Re: convert char array to double
If you want to do a bitwise conversion (which is what you get when you cast) then you need to use either a union or pointers. But don't expect the results to make much sense, because the internal representation of doubles is not ASCII text. If you want the conversion to result in a.x and p containing 3.1415926, then you have to use atof().
Code:
union { |
| All times are GMT +5.5. The time now is 23:13. |