How can one avoid buffer overflows when wanting to format strings or convert numbers to strings? Is there any equivalent functions to for ex. itoa() or sprintf(), where a maximum buffer length can be sent or a required length can be retained? Or is the only way of achieving this by writing your own functions?
Please note that simply allocating a very large buffer is not the solution I am looking for.
Thanks in advance