CHAR STR()

From Lianjapedia
Revision as of 06:46, 11 April 2013 by Yvonne.milne (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

PURPOSE

Convert a number to a character string

SYNONYM

api_char_str()

SYNOPSIS

#include "lianja_api.h"
 
char	*CHAR_STR(buffer, number, width, decimals)
 
<input parameters>
double	number;		/* Number to convert						*/
int	width;		/* Total width of the returned					*/
int	decimals;		/* Number of decimal places					*/
 
<output parameters>
char		buffer;	/* Address of the buffer where the result is returned	*/

DESCRIPTION

The CHAR_STR() function converts the numeric value to right justified character string for the specified width and rounded to the number of decimal places.

EXAMPLE

The following example converts a numeric parameter to a 10 character string pointer with the decimal places rounded to 2.

#include "lianja_api.h"
 
lianjaapi_char_str()
{
    char	buffer[1025]
 
    if ( _parinfo(1) == API_NTYPE) {
       CHAR_STR( buffer, _parnd(1), 10, 2);
    } else {
       strcpy(buffer,"");
    }
 
    _retc( buffer );
}

SEE ALSO

_parc(), _parclen(), _parcsiz(), _parinfo(), _retc(), _retclen(), ISCHAR(), CHAR_ALLTRIM(), CHAR_LOWER(), CHAR_LPAD(), CHAR_LTRIM(), CHAR_RPAD(), CHAR_RTRIM(), CHAR_UPPER(), DATE_STOD()