fscanf() in C language
fscanf( ) function in C, is basically used for read data from the file.
![]() |
| fscanf() in C |
Through this article we will be going to discuss fscanf( ) function of C in detail in which we will cover following topics.
- fscanff( ) function in c
- header file for fscanf( ) function in c
- return value of fscanf( ) function in c
- fscanf( ) function in c syntax
- fscanf( ) function in c program
fscanf( ) function in C
The fscanf( ) 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 read any kind of data and information from the stream(file).
Header file for fscanf( ) 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
fscanf( ) function returns the number argument that where assigned some value on success and if error occur than it returns End of File(EOF).
Syntax of fscanf( ) function in C
int fscanf(FILE *pointer,const char *format,[address,...]):
Example of fscanf( ) function in C
#include<stdio.h>
#include<stdlib.h>
struct student
{
char name [20];
float marks;
}stu;
int main()
{
FILE *fopen(),*fp;
fp=fopen("students.dat","r");
printf("NAME\n");
while(fscanf(fp,"%s",stu.name!=EOF));
printf("%s\n",stu.name);
fclose(fp);
return 0;
}
____________________________________
____________________________________Conclusion
fscanf( ) function in C, is basically used for read data from the file

