sprintf - send formatted output to a string
SYNOPSIS
#include <stdio.h>
int sprintf(string ptr, string format);
DESCRIPTION
sprintf stores in ptr a string formatted along the lines of format.
RETURN VALUE
On success, sprintf returns the total number of characters written to ptr. Otherwise, a negative number is returned.
EXAMPLE
char buffer[50];
int course = 50;
sprintf(buffer,"CS%d rocks!", course);
printf("%s\n", buffer);
%d print out digit
%i print out integer
%f print out float
%c print out character
%s print out string
%2d print out digit using at least 2 characters
%.2d specifies precision
For example:
printf ("Preceding with blanks: %10d \n", 1977);
printf ("Preceding with zeros: %010d \n", 1977);
Output:
Preceding with blanks: 1977
Preceding with zeros: 0000001977