CHAR STR()

From Recital Documentation Wiki
Jump to: navigation, search

PURPOSE

Convert a number to a character string


SYNONYM

api_char_str()


SYNOPSIS

#include "dbapi.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 passed from Recital to a 10 character string pointer with the decimal places rounded to 2.

#include "dbapi.h"
 
dbapi_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()