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>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, 'value', to a string ending
    in a null character ('\0').  The number of digits to be converted is
    specified by 'ndigits'. If 'value' includes more than 'ndigits', the
    low-order digit is rounded.  If 'value' includes fewer than 'ndgits',
    the string is padded with zeros.

    The integer value pointed to by 'decptr' gives the position of the
    decimal point, relative to the start of the string. If the integer is
    0 or a negative value, the decimal point is to the left of the first
    digit.  Similarly, the integer pointed to by 'signptr' indicates the
    sign of the converted number. 0 means the number is positive; any
    other value means the number is negative.

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


      Notes:    ecvt() and fcvt() uses 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