Omnimaga
Calculator Community => TI Calculators => Calculator C => Topic started by: kevinkore3 on June 04, 2014, 09:26:33 pm
-
This is probably a stupid question, but how do you convert types with Ndless? I want to convert a float to a character array (I usually use stringstreams).
-
Can't you just cast it?
if u want to printf it then use %f
Sorry but you have to explain what you want and what doesnt work.
Maybe some example code.
-
You can't just cast a float into a character array. Try to do that manually, by using the % and / operators and some looping. There's probably a standard library function for that though.
-
Use the function to print a formatted string into another string, sprintf(char*, const char*, ...);. Example of use :
// Make sure your string has enough space
char string[100];
float nb = 374619.716183
sprintf(string, "%f", nb);
Also note that sprintf returns the number of characters that were printed.