fscanf() in C language | Detail

 fscanf() in C language

fscanf( ) function in C, is basically used for read data from the file.

fscanf in c language
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.

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

____________________________________

fscanf example in c
____________________________________

Conclusion

fscanf( ) function in C, is basically used for read data from the file
Post a Comment (0)
Previous Post Next Post