... but you'd really want to take a length parameter and call snprintf to prevent buffer overflows. This pre-C99 style C is one of the reasons C has a bad rep wrt memory hazards.
It's converting an int to decimal, so there's an upper bound on how long the string will need to be. You could argue that the length parameter would be superfluous.
Yeah, you can assume everybody will pass a buffer of length at least ten (2^31 has 10 digits).
Oops, make that eleven, for the zero terminator.
Oops, make that twelve, for the sign.
Oops, int can be 64 bits, better make that twenty-one.
Oops, sprintf honors locale. There may be thousands separators in there. Make it twenty-seven (or twenty-eight? I lost count. Also, looking at lconv, decimal points and thousands separators need not be at every third digit and may be more than one character long)
Yeah, I am sure that length parameter is superfluous.
edit: Anyone interested in this should probably read through something newer, like http://c.learncodethehardway.org/book/