CHAR RPAD()

From Lianjapedia
Jump to: navigation, search

PURPOSE

Pad out a character string to the defined length from the right

SYNONYM

api_char_rpad()

SYNOPSIS

#include "lianja_api.h"
 
char	CHAR_RPAD(buffer, string, len, padch)
 
<input parameters>
char	*string;		/* Address of a buffer containing character string		*/
int	len;			/* Total length of the returned string				*/
char	padch;		/* Character to pad with						*/
 
<output parameters>
char	*buffer;		/*Address of the buffer where the result is returned	*/

DESCRIPTION

The CHAR_RPAD() function left justifies a character string and pads out the right of the string, to the total length specified with the specified pad character.

EXAMPLE

The following example pads the right of the first parameter passed to the total length specified by the second parameter with the character passed in the third parameter.

#include "lianja_api.h"
 
lianjaapi_char_rpad()
{
    char	buffer[1025]
 
    if (_parinfo(1) == API_CTYPE &&
       _parinfo(2) == API_NTYPE &&
       _parinfo(3) == API_CTYPE) {
 
       CHAR_LPAD( buffer, _parc(1), _parni(2), _parc(3) );
    } else {
       strcpy(buffer,"");
    }
 
    _retc( buffer );
}

SEE ALSO

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