Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>gcvt() convert double to string</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 gcvt()                  Convert Double to String

 #include   <stdlib.h>                   Required for declarations only

 char       *gcvt(value,ndec,buffer);
 double     value;                       Value to be converted
 int        ndec;                        Number of significant digits stored
 char       *buffer;                     Storage location for results

    gcvt() converts the double 'value' to a character string and stores
    it, plus an automatically appended terminating null character ('\0')
    in 'buffer'.  'buffer' should be large enough to store 'value' plus
    the terminating null character.  gcvt() attempts to produce 'ndec'
    significant digits in FORTRAN F format; if unsuccessful, it attempts
    FORTRAN E format.  Trailing zeros may be suppressed; overflow is not
    provided for.

    Returns:    A pointer to the string of digits; no error return.

 Portability:   Not supported by ANSI standard.

   -------------------------------- Example ---------------------------------

    The following example converts a double value to a string and prints
    it out.

           #include <stdlib.h>
           char buffr[30];
           int declen = 6;

           main()
           {
                gcvt(12.9842,declen,buffr);
                printf("value: %s\n",buffr);
           }



See Also: atof() atoi() atol() ecvt() fcvt()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson