Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ ultostr(3C) — HP-UX 10.20

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

printf(3C)

strtol(3C)

printf(3S)

ltostr(3C)

NAME

ltostr(), ltostr_r(), ultostr(), ultostr_r(), ltoa(), ltoa_r(), ultoa(), ultoa_r() − convert long integers to strings

SYNOPSIS

#include <stdlib.h>

char *ltostr(long n, int base);

int ltostr_r(long n, int base, char *buffer, int buflen);

char *ultostr(unsigned long n, int base);

int ultostr_r(unsigned long n, int base, char *buffer, int buflen);

char *ltoa(long n);

int ltoa_r(long n, char *buffer, int buflen);

char *ultoa(unsigned long n);

int ultoa_r(unsigned long n, char *buffer, int buflen);

DESCRIPTION

ltostr() Convert a signed long integer to the corresponding string representation in the specified base.  The argument base must be between 2 and 36, inclusive. 

ultostr() Convert an unsigned long integer to the corresponding string representation in the specified base.  The argument base must be between 2 and 36, inclusive. 

ltoa() Convert a signed long integer to the corresponding base 10 string representation, returning a pointer to the result. 

ultoa() Convert an unsigned long integer to the corresponding base 10 string representation, returning a pointer to the result. 

These functions are smaller and faster than using sprintf() for simple conversions (see printf(3S)).

Reentrant Interfaces

For the reentrant (_r) interfaces, the result string is passed back in the supplied buffer.  If the buffer is of insufficient length, −1 is returned.  If the operation is successful, the length of the result string (not including the terminating null character) is returned. 

ERRORS

If the value of base is not between 2 and 36, ltostr() and ultostr() return NULL and set the external variable errno to ERANGE.  The reentrant versions (ltostr_r() and ultostr_r()) return −1 and set the external variable errno to ERANGE. 

WARNINGS

The return values for ltostr(), ultostr(), ltoa(), and ultoa() point to static data whose content is overwritten by each call. 

ltostr(), ultostr(), ltoa(), and ultoa() are unsafe in multi-thread applications.  ltostr_r(), ultostr_r(), ltoa_r(), and ultoa_r() are MT-Safe and should be used instead. 

AUTHOR

ltostr(), ultostr(), ltoa(), and ultoa() were developed by HP. 

SEE ALSO

printf(3C), strtol(3C), printf(3S). 

Hewlett-Packard Company  —  HP-UX Release 10.20:  July 1996

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026