Sprintf in C : It's just like printf but output is sent to a string, rather than standard output.
It's used when we wish to store integers or floats in a string. The first argument is a pointer to string. Previous content of string are overwritten.
C program
#include<stdio.h>
int main()
{
int a = 1;
float b = 1.23;
char c = 'u', string[100] = "My initial character array.";
printf("%s\n", string);
sprintf(string, "Integer = %d, Float = %f, Character = %c.", a, b, c);
printf("%s\n", string);
return 0;
}