_gcvt (Windows CE 5.0)

Send Feedback

Developing an Application > Microsoft C Run-time Library for Windows CE > Run-time Library Reference

Converts a floating-point value to a string, which it stores in a buffer.

char *_gcvt(    doublevalue,intdigits,char*buffer 
);

Parameters

  • value
    Value to be converted.
  • digits
    Number of significant digits stored.
  • buffer
    Storage location for result.

Return Values

_gcvt returns a pointer to the string of digits.

There is no error return.

Remarks

The _gcvt function converts a floating-point value to a character string (which includes a decimal point and a possible 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 digitsdigits in decimal format. If it cannot, it produces digits digits in exponential format. Trailing zeros might be 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.'

Requirements

OS Versions: Windows CE 2.0 and later.
Header: stdlib.h.
Link Library: coredll.dll.

See Also

atof | _ecvt | _fcvt

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.