Compare the versatility of sprintf() to multiple functions in your code:
Code:#include <stdio.h> int main(void) { int ival = 1234; double dval = 1.2345; char ary[64] = ""; // Build a string with an int, int in Hex, address of the int, and the the double sprintf(ary, "int=%d, hex=%x, addr=%p, double=%lf\n", ival, ival, (void *) &ival, dval); printf("ary = %s\n", ary); return 0; }Code:Output: ary = int=1234, hex=4d2, addr=0x7ffd3ba48224, double=1.234500