The following program reads the formatted data from the file.
- #include<stdio.h>
- #include<conio.h>
- void main()
- {
- FILE *fp;
- char name[20];
- int age;
- float salary;
- clrscr();
- if((fp==fopen("text1.dat","r"))==NULL)
- {
- exit(1);
- }
- while(fscanf(fp,"%s%d%f",name,&age,&salary)!=EOF)
- fclose(fp);
- getch();
- }
tags: C programming Examples , File handling programs in C , Programming Examples on Files in C , Program to read formatted data from a file in C
Post a Comment