Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <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 in 'buffer'.  'buffer' should be large enough to store 'value'
    plus a terminating null character ('\0'), which is automatically
    appended.  gcvt() attempts to produce 'ndec' significant digits in
    FORTRAN F format or, if unsuccessful, FORTRAN E format.  Trailing
    zeros may be suppressed. There is no provision for overflow.

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

   -------------------------------- 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