
25
address of the first byte meets the requirements for storing any type
of C variable). If the memory allocation is unsuccessful because of
insufficient space or bad values of the arguments, a NULL is
returned.
Comments
:
Note that when using
Tmolloc
to allocate storage for a specific data
type, you should cast the returned
void
pointer to that type.
◆
Data Conversion Routines
__itoa
Purpose
:
Use
__itoa
to convert an integer value to a null-terminated character
string.
Syntax
:
char * __itoa (int value, char *string, int radix);
Example call
:
__itoa(32, buffer, 16); /* buffer will contain “20” */
Includes
:
#include
“
UserLib.h
"
Description
:
The
__itoa
function converts the
int
argument
value
into a
null-terminated character string using the argument
radix
as the base
of the number system. The resulting string with a length of up to 17
bytes is saved in the buffer whose address is given in the argument
string
. You must allocate enough room in the buffer to hold all digits
of the converted string plus the terminating null character (\0). For
radixes other than 10, the sign bit is not interpreted; instead, the bit
pattern of
value
is simply expressed in the requested
radix
. The
argument
radix
specifies the base (between 2 and 36) of the number
system in which the string representation of
value
is expressed. For
example, using either 2, 8, 10, or 16 as
radix
, you can convert
value
into its binary, octal, decimal, or hexadecimal representation,
respectively. When
radix
is 10 and the
value
is negative, the
converted string will start with a minus sign.
Returns
:
The
__itoa
function returns the pointer to the string of degits (i.e., it
returns the argument
string
).
__ltoa
Purpose
:
Use
__ltoa
to convert a long integer value to a null-terminated
character string.
Syntax
:
char * __ltoa (long value, char *string, int radix);
Example call
:
__ltoa(0x10000, string, 10); /* string = “65536” */
Includes
:
#include
“
UserLib.h
"
Содержание PT-10
Страница 4: ...3 Keyboard Wedge 99 System 101 Power 102 Other 102 ...
Страница 13: ...12 6 Development Flow Chart ...
Страница 53: ...52 Returns No returns Notes ...