fprintf() in C language
fprintf( ) function in C , is basically used to write a data in the file
![]() |
| fprinf() in C |
Through this article we will be going to discuss fprintf( ) function of C in detail in which we will cover following topics.
- fprintf( ) function in c
- header file for fprintf( ) function in c
- return value of fprintf( ) function in c
- fprintf( ) function in c syntax
- fprintf( ) function in c program
fprintf( ) function in C
The fprintf( ) function is nothing but, it is a standard library function of C and it also called file handling function of C which is basically used to write any kind of data and information in the stream(file).
Header file for fprintf( ) function in C
This file function is define in <stdio.h> which is stand for standard input-output header file.
Return value of fprintf( ) function in C
fprintf( ) function returns the number character output to the file on success and if error occur than it returns End of File(EOF).
Syntax of fprintf( ) function in C
int fprintf(FILE *pointer,const char *format,[argument]):
Example of fprintf( ) function in C
#include<stdio.h>
#include<stdlib.h>
int main()
{
FILE *fp;
char name[10];
int age;
fp=fopen("rec.dat","w");
printf("Enter your name and age");
scanf("%s%d",name,&age);
fprintf(fp,"name=%s & age=%d",name,age);
fclose (fp) ;
return 0;
}
____________________________________
____________________________________
Conclusion
fprintf( ) function in C , is basically used to write a data in the file.

