Difference between revisions of "CHAR STR()"

From Lianjapedia
Jump to: navigation, search
m (1 revision)
m (Text replace - "lianjaapi.h" to "lianja_api.h")
 
Line 7: Line 7:
 
==SYNOPSIS==
 
==SYNOPSIS==
 
<code lang="c">
 
<code lang="c">
#include "lianjaapi.h"
+
#include "lianja_api.h"
  
 
char *CHAR_STR(buffer, number, width, decimals)
 
char *CHAR_STR(buffer, number, width, decimals)
Line 27: Line 27:
  
 
<code lang="c">
 
<code lang="c">
#include "lianjaapi.h"
+
#include "lianja_api.h"
  
 
lianjaapi_char_str()
 
lianjaapi_char_str()

Latest revision as of 06:46, 11 April 2013

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()