The sprintf() function is used for assigning formatted text to a string. Here is its syntax:
int sprintf(char *str, const char *format, ...)
Here, str is a pointer to the string where the formatted string has to be assigned, and format is the same as in a printf statement, where different formatting tags such as %d and %s can be used to format the content.