/*
_ecvt_s Converts a double number to a string.
Syntax:
errno_t _ecvt_s(
char * _Buffer,
size_t _SizeInBytes,
double _Value,
int _Count,
int *_Dec,
int *_Sign
);
[out] _Buffer
Filled with the pointer to the string of digits, the result of the conversion.
[in] _SizeInBytes
Size of the buffer in bytes.
[in] _Value
Number to be converted.
[in] _Count
Number of digits stored.
[out] _Dec
Stored decimal-point position.
[out] _Sign
Sign of the converted number.
*/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
...
char *buf = (char*) malloc(_CVTBUFSIZE);
int decimal;
int sign;
int err;
err = _ecvt_s(buf, _CVTBUFSIZE, 1.2, 5, &decimal, &sign);
if (err != 0) {
// implement error handling
}
else printf("Converted value: %s\n", buf);
...
希望这可以帮助。