C Language: vfprintf function
(Formatted File Write Using Variable Argument List)
In the C Programming Language, the vfprintf function writes formatted output to stream using arg as the variable argument list.
Syntax
The syntax for the vfprintf function in the C Language is:
int vfprintf(FILE *stream, const char *format, va_list arg);
Parameters or Arguments
- stream
- The stream where the output will be written.
- format
Describes the output as well as provides 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 format 10.500000 %.1f Displays a floating-point number with 1 digit after the decimal 10.5 %e Display a floating-point number in exponential (scientific notation) 1.050000e+01 %g Display a floating-point number in either fixed decimal or exponential format depending on the size of the number (will not display trailing zeros) 10.5 - arg
- A variable argument list.
Returns
The vfprintf function returns the number of characters that was written. If an error occurs, it will return a negative value.
Required Header
In the C Language, the required header for the vfprintf function is:
#include <stdio.h>
Applies To
In the C Language, the vfprintf function can be used in the following versions:
- ANSI/ISO 9899-1990
Similar Functions
Other C functions that are similar to the vfprintf function:
- fprintf function <stdio.h>
- printf function <stdio.h>
- sprintf function <stdio.h>
- vprintf function <stdio.h>
- vsprintf function <stdio.h>
See Also
Other C functions that are noteworthy when dealing with the vfprintf function:
Advertisements