-->

NEB33":WAP to store book's name,price and author's name in a file namd 'book.dat'.

//WAP to store book's name,price and author's name in a file named 'book.dat'.
#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","w");
printf("enter book's name and author's name\n");   // getting inuts
gets(book_name);
printf("enter author's name\n");
gets(author_name);
printf("enter book's price\n");
scanf("%d",&book_price);
fprintf(k,"%s %s %d",book_name,author_name,book_price);   //writing data to data file
printf("writing process completed successflly\n");
fclose(k);                                                                                   //closing data file
getch();
}




No comments:

Post a Comment