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>ecvt() convert double to string</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 ecvt()                  Convert Double to String

 #include <stdlib.h>

 char       *ecvt(value,ndigits,decptr,signptr);
 double     value;                       Number to be converted
 int        ndigits;                     Number of digits stored
 int        *decptr;                     Ptr to stored decimal point position
 int        *signptr;                    Pointer to stored sign indicator

    ecvt() converts a floating-point number to a string.  'value' is the
    number to be converted.  ecvt() stores 'ndigits' number of digits of
    'value' as a string and appends a null character ('\0').  If there
    are more digits than 'ndigits', the low-order digit is rounded.  If
    there are fewer digits than 'ndIgits', the string is padded with
    zeros.

    'decptr' points to an integer value giving the position of the
    decimal point relative to the beginning of the string (0 or negative
    value means the decimal point is to the left of the first digit).
    'signptr' points to an integer indicating the sign of the converted
    number. (A zero value means the number is positive; any other value
    means the number is negative.)

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

         Notes:     ecvt() and fcvt() use a statically allocated buffer
                    for conversion.  Each call to these routines destroys
                    the results of a previous call.

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

    The following statements store a double value in a string and then
    print it out.

           #include <stdlib.h>

           int decpt, sign;
           char *string;
           int length = 6;
           double val = 24.62941;

           main()
           {
               string = ecvt(val,length,&decpt,&sign);
               printf("%s",string);
           }


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

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