Pointer to the file stream where the output will be written
2nd Parameter Type : const char *
Pointer to read-only string
2nd Parameter
A null-terminated string specifying how to format the output
3rd Parameter Type : ...
Represents a variable number of arguments in a function. Used in functions like `printf` or `fprintf` to accept additional parameters beyond those explicitly declared.
3rd Parameter
A variable number of arguments to be formatted according to the `format` string
Read more about parameters of fprintf in parameters section
The fprintffunction in C language Writes formatted output to a stream.
The fprintf function writes output to the stream pointed to by stream, under control of the string pointed to by format that specifies how subsequent arguments are converted for output. It behaves exactly like printf, but writes to the specified stream instead of stdout.
The fprintffunction takes 3
parameters:
•
FILE * `stream`: Pointer to the file stream where the output will be written
•
const char * `format`: A null-terminated string specifying how to format the output
•
... `args`: A variable number of arguments to be formatted according to the `format` string
Writes formatted output to the specified file stream according to the `format` string and additional arguments. Returns the number of characters written, or a negative value if an error occurs.
The fprintf function return value :
Returns the number of characters written if successful, or a negative value if an error occurred
Output
This example demonstrates the basic usage of `fprintf`. It writes formatted output to a file, including an integer and a string.