it
来自「Algorithms for Image Processing and Comp」· 代码 · 共 42 行
TXT
42 行
@c ----------------------------------------------------------------------
@node itoa, string
@heading @code{itoa}
@subheading Syntax
@example
#include <stdlib.h>
char * itoa(int value, char *buffer, int radix);
@end example
@subheading Description
This function converts an integer @var{value} to it's string
representation. If @var{radix} is 10, the value is treated as a
signed value, and the resulting string may have a prepended minus
sign. For all other values of @var{radix}, the value is treated as
unsigned.
The buffer you pass must be large enough to hold the largest returned
string. Since @var{radix} must be in the range 2 through 36, the
largest buffer would be 33 characters (including the trailing null).
If you pass NULL for the @var{buffer}, one is allocated for you, which
you must later free.
For values of @var{radix} larger than 10, characters in the range
@code{a} through @code{z} are used to represent the digits after
@code{9}.
@subheading Return Value
A pointer to @var{buffer} or the allocated buffer.
@subheading Example
@example
char buf[33];
itoa(val, buf, 16);
printf("%d = 0x%s\n", val, buf);
@end example
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?