CHAR RPAD()

From Recital Documentation Wiki
Revision as of 11:13, 30 March 2009 by Yvonnemilne (Talk | contribs)

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

PURPOSE

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


SYNONYM

api_char_rpad()


SYNOPSIS

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