fprintf() in C language | Detail

 fprintf() in C language

fprintf( ) function in C , is basically used to write a data in the file

fprintf() in C language
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.

  1. fprintf( ) function in c
  2. header file for fprintf( ) function in c
  3. return value of fprintf( ) function in c
  4. fprintf( ) function in c syntax
  5. 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;
}

____________________________________

example of fprintf in c

____________________________________

Conclusion

fprintf( ) function in C , is basically used to write a data in the file.
Post a Comment (0)
Previous Post Next Post