In the C Programming Language, the sprintf function writes formatted output to an object pointed to by means of s.
Syntax
The syntax for the sprintf function in the C Language is:
int sprintf(char *s, const char *format, ...);
Parameters or Arguments
s An array the place the output will be written. format Describes the output as properly as offers a placeholder to insert the formatted string. Here are a few examples: Format Explanation Example %d Display an integer 10 %f Displays a floating-point number in fixed decimal layout 10.500000 %.1f Displays a floating-point variety with 1 digit after the decimal 10.5 %e Display a floating-point variety in exponential (scientific notation) 1.050000e+01 %g Display a floating-point wide variety in either fixed decimal or exponential layout relying on the measurement of the variety (will not show trailing zeros) 10.5
Returns
The sprintf function returns the variety of characters saved in the array (not along with the null character).
Required Header
In the C Language, the required header for the sprintf characteristic is:
#include <stdio.h>
Applies To
In the C Language, the sprintf function can be used in the following versions:
ANSI/ISO 9899-1990
Similar Functions
Other C features that are comparable to the sprintf function:
fprintf feature printf feature vfprintf feature vprintf feature vsprintf feature
See Also
Other C features that are noteworthy when dealing with the sprintf function:
fscanf function scanf function sscanf characteristic
Leave a Review