#include<iostream.h>
#include<conio.h>
#include<stdio.h>
struct BOOK
{
int Bno;
char Bname[20];
char Author[20];
float Price;
};
void EnterDetails(BOOK A[], int);
void DisplayDetails(BOOK A[], int);
void SearchByBno(BOOK A[]);
void SearchByBname(BOOK A[]);
void main()
{
clrscr();
int n;
BOOK B[20];
cout<<"Enter the number of different books you would be entering: ";
cin>>n;
EnterDetails(B,n);
DisplayDetails(B,n);
SearchByBno(B);
SearchByBname(B);
getch();
}
void EnterDetails(BOOK A[], int N)
{
for(int i=0; i<N; i++)
{
cout<<"Enter the details of Book"<<i+1<<":"<<endl;
for(int j=0; j<N; j++)
{
cout<<"Enter book number: ";
cin>>A.Bno;
cout<<"Enter book name: ";
gets(A.Bname);
cout<<"Enter Author of the book: ";
gets(A.Author);
cout<<"Enter price of the book in $: ";
cin>>A.Price;
}
}
}
void DisplayDetails(BOOK A[], int N)
{
for(int i=0; i<N; i++)
{
cout<<"Details of book "<<i+1<<" "<<"are: "<<endl;
for(int j=0; j<N; j++)
{
cout<<"Book number: ";
cout<<A.Bno;
cout<<"Book name: ";
cout<<A.Bname;
cout<<"Author: ";
cout<<A.Author;
cout<<"Price: ";
cout<<A.Price;
}
}
}
void SearchByBno(BOOK A[])
{
cout<<"Enter book number of the book you are looking for: ";
cin>>A.Bno;
cout<<"The details of the book you are looking for are: ";
cout<<"Book number: ";
cout<<A.Bno;
cout<<"Book name: ";
cout<<A.Bname;
cout<<"Author: ";
cout<<A.Author;
cout<<"Price: ";
cout<<A.Price;
}
void SearchByBname(BOOK A[])
{
cout<<"Enter the name of the book you are looking for: ";
gets(A.Bname);
cout<<"The details of the book you are looking for are: ";
cout<<"Book number: ";
cout<<A.Bno;
cout<<"Book name: "<<A.Bname;
cout<<"Author: "<<A.Author;
cout<<"Price: "<<A.Price;
}
The errors are: In line 43,45,47,49,61,63,65,67,76,79,81,83,85,92,95,96,97,98:
"Structure required on left side of . or .*"
But the program has a structure A in all these lines before the left..whats the problem then? In line 52,70,86,99:
"Parameter A is never used"
But it is used everywhere in these lines all along! BTW these 4 errors are not specifically present in these 4 lines..they are for the 4 functions have A as a parameter, so it says that parameter A is never used all along while defining these functions which is not true as it can be seen!
Need help!
But the program has a structure A in all these lines before the left.
No. A is not a structure. It's a pointer to a structure.
"Parameter A is never used"
Probably a consequence of the previous error. A is not used in any lines that the compiler considers to be valid C++. In this, the compiler is absolutely correct.