[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
sprintf() Write Formatted Data to String
#include <stdio.h>
int sprintf(buffer,format-string[,argument...]);
char *buffer; Storage location for output
char *format-string; Format-control string
sprintf() formats and stores a series of characters and values in
'buffer'. sprintf() operates identically to printf(), with the
exception that sprintf() "prints" to a buffer, while printf() prints
to stdout. With that single exception, the two functions are
identical; see the printf() function for a complete description of
the format-string and arguments.
-------------------------------- Example ---------------------------------
The following statements format and store data in 'buffer'.
#include <stdio.h>
char buffer[100];
char *name = "Ali Rae";
char age = '1';
char s = 'F';
main()
{
sprintf(buffer,"%s, %c, %c",name,age,s);
printf("Birthdays this month: %s\n",buffer);
}
See Also:
printf()
fprintf()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson