Is there a reason the itoa () function returns void and stores the result in the char [] array passed to it instead of returning char []?
The reason is because the function expects the caller to allocate and provide a buffer. This is very standard for C. If the function returned a new buffer, the caller would need to take care to free it, and this would cause the buffer to be dynamically allocated. By asking the caller to provide a buffer, the function allows you to allocate a buffer with automatic storage or dynamically allocate.
, itoa, , , , void.
itoa
void
C .
, C ; .
static
malloc()
free()
-, itoa() 1, , , .
itoa()
, itoa(), ISO C, POSIX. -, C , , (Solaris Linux), . , , , sprintf snprintf.
sprintf
snprintf
, itoa , void. , , const char * C. , itoa ANSI-C ( , ).
const char *