Piuttosto usa la snprintf (non inclusa nello standard C89 ma molto diffusa, poi diventata standard nel C99), in modo da evitare i buffer overflow.