What is the error?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#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!
In void EnterDetails(BOOK A[], int N), A is declared to be a pointer or an array. So A.Bname is a syntax error.

You probably mean A[i].Bname. The same applies throughout.
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.
Hmm..thanks! :)
Topic archived. No new replies allowed.