¿Le resultó útil esta página?
Sus comentarios sobre este contenido son muy importantes. Háganos saber su opinión.
¿Tiene comentarios adicionales?
Caracteres restantes: 1500
Exportar (0) Imprimir
Expandir todo
Expandir Minimizar
Importante Es posible que este documento no represente los procedimientos recomendados para el desarrollo actual. Puede que los vínculos a las descargas y otros recursos ya no sean válidos. Encontrará aquí la versión que se recomienda en la actualidad.


Converts a floating-point number to a string. This function is deprecated because a more secure version is available; see _fcvt_s.

char *_fcvt( 
   double value,
   int count,
   int *dec,
   int *sign 



Number to be converted.


Number of digits after the decimal point.


Pointer to the stored decimal-point position.


Pointer to the stored sign indicator.

_fcvt returns a pointer to the string of digits, NULL on error.

The _fcvt function converts a floating-point number to a null-terminated character string. The value parameter is the floating-point number to be converted. _fcvt stores the digits of value as a string and appends a null character ('\0'). The count parameter specifies the number of digits to be stored after the decimal point. Excess digits are rounded off to count places. If there are fewer than count digits of precision, the string is padded with zeros.

The total number of digits returned by _fcvt will not exceed _CVTBUFSIZE.

Only digits are stored in the string. The position of the decimal point and the sign of value can be obtained from dec and sign after the call. The dec parameter points to an integer value; this integer value gives the position of the decimal point with respect to the beginning of the string. A zero or negative integer value indicates that the decimal point lies to the left of the first digit. The parameter sign points to an integer indicating the sign of value. The integer is set to 0 if value is positive and is set to a nonzero number if value is negative.

The difference between _ecvt and _fcvt is in the interpretation of the count parameter. _ecvt interprets count as the total number of digits in the output string, whereas _fcvt interprets count as the number of digits after the decimal point.

_ecvt and _fcvt use a single statically allocated buffer for the conversion. Each call to one of these routines destroys the results of the previous call.

This function validates its parameters. If dec or sign is NULL, or count is 0, the invalid parameter handler is invoked, as described in Parameter Validation. If execution is allowed to continue, errno is set to EINVAL and NULL is returned.

Function Required header Compatibility



Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition, Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003

For more compatibility information, see Compatibility in the Introduction.

// crt_fcvt.c
// compile with: /W1
// This program converts the constant
// 3.1415926535 to a string and sets the pointer
// buffer to point to that string.

#include <stdlib.h>
#include <stdio.h>

int main( void )
   int  decimal, sign;
   char *buffer;
   double source = 3.1415926535;

   buffer = _fcvt( source, 7, &decimal, &sign ); // C4996
   // Note: _fcvt is deprecated; consider using _fcvt_s instead
   printf( "source: %2.10f   buffer: '%s'   decimal: %d   sign: %d\n",
            source, buffer, decimal, sign );


source: 3.1415926535   buffer: '31415927'   decimal: 1   sign: 0

Adiciones de comunidad

© 2015 Microsoft