Program to enter details of ‘n’ number of book and display back all records on screen by using concept of array of structure with access by pointer

#include
#include
struct book
{
char name[20];
int nop;
char author[20];
float price;
}a[10];

main()
{
int n,i;
struct book *p[70];
clrscr();
cout<>n;
for(i=1;i<=n;i++)
{

p[i]=&a[i];
cout<<"nBook number: "<<i;
cout<>p[i]->name;
cout<>p[i]->nop;
cout<>(*p[i]).author;
cout<>p[i]->price;
cout<<"nThe entered records are: n";
}

clrscr();
cout<<"nS.notNamettN_OF_PAGEtAUTHOR_NAMEtPrice";
for(i=1;i<=n;i++)
{
cout<<"n"<<i<<"t"<<(*p[i]).name<<"tt"<<(*p[i]).nop<<"tt"<<(*p[i]).author<<"tt"<price;
}
getch();
}

Leave a Reply

Your email address will not be published. Required fields are marked *