simple _itoa_s question

When using : _ito_s(...); can the length of buffer be, say 10, and the actual length of integer data be less? I am using Microsoft Visual C++ 2008 Express Edition.

Thank you,
Joshua Eirman

Last edited on
Yes. You have to ensure that the buffer is large enough to hold the converted value.
If the buffer is created on the stack then you don't need to specify any buffer size, it is detected automatically at compile time (for C++, not C language)
kbw,

You are certain that the larger buffer length parameter is okay with the underscored s function?

I am confused because the parameters are diferent than the regular _itoa.

If the buffer is ten and the buffer length of the integer is five and the parameter is ten for length will the result be a valid five char string ?
This will be automatically be \0 ended assuming the buffer length parameter
is large enough to hold it?


Thank you,
Joshua Eirman

P.S. the buffer is also reuseable without modification (such as ++, --, etc.?)

Last edited on
Topic archived. No new replies allowed.