[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]


sprintf

Format a character string array.

Compatibility:

This function is compatible with the following targets:

ANSI

BeOS

EMB/RTOS

Mac OS

Palm OS

Win32


Prototype:
#include <stdio.h>
int sprintf(char *s, const char *format, ...);
Parameters:

Parameters for this facility are:

s  
char *  
A string to write to  
format  
const char *  
The format string  

Remarks:

The sprintf() function works identically to printf() with the addition of the s parameter. Output is stored in the character array pointed to by s instead of being sent to stdout. The function terminates the output character string with a null character.

For specifications concerning the output control string and conversion specifiers please see: "Output Control String and Conversion Specifiers."

Return:

sprintf() returns the number of characters assigned to s, not including the null character.

See Also:

"Wide Character and Byte Character Stream Orientation"

"fprintf"

"printf"

Example of sprintf() usage.:
#include <stdio.h>

int main(void)
{
	int i = 1;
	static char s[] = "Metrowerks";
	char dest[50];

	sprintf(dest, "%s is number %d!", s, i);
	puts(dest);

	return 0;
}

Output:
Metrowerks is number 1!


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: August 16, 2000