Here are two examples
Example 1
#include <windows.h>
#include <stdio.h>
int main(void) {
double myDOUBLE=123.456;
char* mySTRING=GlobalAlloc(GMEM_FIXED,64); //allocate string in memory
_strnset(mySTRING,0,1); //initilize mySTRINGto ""
int i;
i = sprintf(mySTRING, "%G", myDOUBLE);
printf("123.456 as a string is %s\n", mySTRING);
printf("sprintf returns: %d\n\n", i);
return 0;
}
Example 2
#include <stdio.h>
int main(void) {
double dub1 = 123.456;
char str1[10];
int i;
i = sprintf(str1, "%G", dub1);
printf("123.456 as a string is %s\n", str1);
printf("sprintf returns: %d\n\n", i);
return 0;
}
I hope this helps.
Robert Wishlaw