//WAP top read all records stored in a file book.dat. Fields are name,price and author's name.
#include<stdio.h>
include<conio.h>
void main()
{
FILE *k; // pointer for file declaration
char book_name[30],author_name[40]; //identifier declaration
int book_price; // " "
k=fopen("book.dat","r");
while((fscanf(k,"%d %s %s",&book_price,book_name,author_name)!=EOF))//reading data from data file
{
printf("book name=%s ,author name=%s and price=%d",book_name,author_name,book_price); //displaying data
}
fclose(k); //closing data file
getch();
}
#include<stdio.h>
include<conio.h>
void main()
{
FILE *k; // pointer for file declaration
char book_name[30],author_name[40]; //identifier declaration
int book_price; // " "
k=fopen("book.dat","r");
while((fscanf(k,"%d %s %s",&book_price,book_name,author_name)!=EOF))//reading data from data file
{
printf("book name=%s ,author name=%s and price=%d",book_name,author_name,book_price); //displaying data
}
fclose(k); //closing data file
getch();
}