Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ Language Reference - ecvt http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
   ecvt

   Usage
   #include <stdlib.h>
   char *ecvt(double val,int ndig,int *pdecpt,int *psign);

   Description
   Converts  the double value val into a string and returns a pointer  to
   that string. The number of digits to be created is given by ndig.  The
   digit  string is rounded if the actual number of digits exceeds  ndig.
   The  string  is  padded with 0's if ndig is greater  than  the  actual
   number  of  digits.  As  only digits are stored  in  the  string,  the
   position of the decimal point relative to the left of the first  digit
   in  the  string  is stored in the integer pointed to  by  *pdecpt.  If
   *pdecpt is negative, the decimal point is positioned that many  places
   to the left of the string. Into *psign is stored 0 if val >= 0,  else
   a non-zero value.

   The  string is written into a statically allocated area,  shared  with
   fcvt and printf, which is reused at each call.

   Example
   #include <stdio.h>
   #include <stdlib.h>

   main()
   {
   char *buffer;
   int dec, sign;

   buffer = ecvt(98.69138432, 5, &dec, &sign);
   printf("buffer = \"%s\", decimal = %d, sign = %d\n",buffer,dec,sign);
   }

   Return Value
   Returns  a  pointer to the string of digits, which is  overwritten  by
   each call to ecvt, fcvt or printf.


See Also: fcvt sprintf

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