I think af7567 hit it. That's the first thing I noticed too.
If you want to store a string representation of a float, you don't do something like:
Code:
char *myFloatString = (char *)malloc(sizeof(float)); // WRONG!
If you want a string representation of a float, you'd do something like this:
Code:
#include <stdio.h>
#include <math.h>
int main (int argc, char *argv[]) {
char myFloatString[10];
sprintf (myFloatString, "%f", M_PI);
printf ("%s\n", myFloatString);
return 0;
}
Output:
Code:
$ ./floattest
3.141593
If you want more digits, you need to use a double or double double and allocate more characters.