There may be a lot of people, including C-language veterans who don't know how to convert float data to string, that's what I did, I checked MSDN today to know that C provides the _GCVT function to achieve this function, the harvest is really not small, in order to facilitate their own inquiries, And for those like me who can understand the exact usage of the function, I copy the MSDN text as follows:
return Value
_gcvt Returns a pointer to the string of digits. There is no error return.
Parameters
Value
Value to is converted
Digits
Number of significant digits stored
Buffer
Storage location for result
remarks
The _gcvt function converts a floating-point value to a character string (which includes a decimal point and a PO Ssible sign Byte) and stores the string in buffer. The buffer should be large enough to accommodate the converted value plus a terminating null character, which is appended automatically. If a buffer size of digits + 1 is used, the function overwrites the end of the buffer. This is because the converted string includes a decimal point and can contain sign and exponent information. There is no provision for overflow. _GCVT attempts to produce digits digits in decimal format. If it cannot, it produces digits digits in exponential format. Trailing zeros May is suppressed in the conversion.
Example
/* _gcvt. C:this program Converts-3.1415e5
* to its string representation.
* *
#include <stdlib.h>
#include <stdio.h>
void main (void)
{
char buffer[50];
Double Source = -3.1415e5;
_GCVT (source, 7, buffer);
printf ("Source:%f buffer: '%s '/n", source, buffer);
_GCVT (source, 7, buffer);
printf ("Source:%e buffer: '%s '/n", source, buffer);
}
Output
Source: -314150.000000 buffer: ' -314150. '
Source: -3.141500e+005 buffer: '-314150. '