Write a program to read formatted data from the file. 6m Jun2008
CODE:-
#include<stdio.h>
void main()
{
int account;
char name[30];
double bal;
FILE *fp;
if((fp=fopen(“data.txt”,”r”))== NULL)
printf(“FILE not present \n”);
else
do{
fscanf(fp,”%d%s%lf”,&account,name,&bal);
if(!feof(fp))
{
if(bal==0)
printf(“%d %s %lf\n”,account,name,bal);
}
}while(!feof(fp));
getch();
}
[codesyntax lang=”c”]
#include<stdio.h> void main() { int account; char name[30]; double bal; FILE *fp; if((fp=fopen("data.txt","r"))== NULL) printf("FILE not present \n"); else do{ fscanf(fp,"%d%s%lf",&account,name,&bal); if(!feof(fp)) { if(bal==0) printf("%d %s %lf\n",account,name,bal); } }while(!feof(fp)); getch(); }
[/codesyntax]
ScreenShots: