I need to convert a char array into int and float using C The array is like this
char* text = "15.34";
I also need to convert a float/int back into an array again
I need to convert a char array into int and float using C The array is like this
char* text = "15.34";
I also need to convert a float/int back into an array again
Use atoi()
/strtol()
and atof()
/strtod()
library functions to convert from string.
To convert back use sprintf()
with %d
and %f
format specifiers.
You can use sscanf also. For example:
float fp = 0; sscanf( text, "%f", &fp );
To convert back use sprintf()