My program shows function declared as void

WritMy program shows function declared as void .The program is about library system . User can enter books ,cost and auther name and book id and after entring data it displays it on the secreen.The structure takes input but does not display the entered records .pLease help me .


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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
  #include<iostream>

#include<string>

using namespace std;
struct book
{
		char book_name[50];
		char book_auth[50];	
		int	Book_ID;
		int Cost_Book;
	};

void search();
void dis_books();
void add_books();
void choice();
void mnu();
void dis_books(b1[no_books]);

void cont();//continue of  exit the program

	 char yorn;
		


void dis_books(b1[no_books]){
	cout<<"The details of the Books are given below"<<endl;
	for(int i=0;i<=5;i++){
		cout<<"Book id"<<"="<<b1[i].Book_ID<<endl;
		cout<<"Book name is"<<"="<<b1[i].book_name<<endl;
		cout<<"Book auther is"<<"="<<b1[i].book_auth<<endl;
	}
	
	
	
}
void choice(){
	int choice;
	mnu();
	cin>>choice;
	do{	
	
		switch(choice){
			case 1:
				add_books();
		cout<<"Press y/n to continue"<<endl;
		cin>>yorn;
		if(yorn=='y'){
			mnu();
			cin>>choice;
		}
		break;
		
		case(2):
			book b3[2];
			dis_books();
			cout<<"Press y/n to continue"<<endl;
		cin>>yorn;
		if(yorn=='y'){
			mnu();
			cin>>choice;
		}
			break;
		
		default:
			mnu();
			cin>>choice;
		cout<<"Press y/n to continue"<<endl;
		cin>>yorn;
		}
				
	
	
if(choice!=1|choice!=2|choice!=3|choice!=4|choice!=5){
		cout<<"Please make your choice"<<endl;
			mnu();
			cin>>choice;
			}
}
while(yorn=='y');

}


void add_books(){
	int no_books;
	int id;
cout<<"Please enter number of books"<<endl;
cin>>no_books;
cout<<"::Lets adding records::"<<endl;
	for(int i=0;i<=0;i++){
		cout<<"The book id is"<<"="<<i+1<<endl;
		b1[i].	Book_ID=i+1;
		cout<<"Please enter book name"<<endl;
		//cin.ignore();
		cin.getline(b1[i].book_name,50);
		cout<<"Please enter auther name"<<endl;
		cin.getline(b1[i].book_auth,50);
		cout<<"Please enter the cost of the book"<<endl;
		cin>>b1[i].Cost_Book;

	}	
}

void mnu(){//function for displaying menu
cout<<"---------------------------Library Management System-------------------------------"<<endl;
cout<<"Library Management system"<<endl;
cout<<"Press 1 To Enter a Book Record"<<endl;
cout<<"Press 2 To Display all Records of Books Available in Library"<<endl;
cout<<"Press 3 To Search Books by Author Name."<<endl;
cout<<"Press 4 To Count Total Books in Library"<<endl;
cout<<"Press 5 To Exit from the System"<<endl;	
}


int main(){
	choice();
	
//	book b3[2];
//	for (int i=0;i<2;i++){
//		cout<<"Please enter book name"<<endl;
//		cin>>b3[i].book_name;
//		cout<<"Please enter cost"<<endl;
//		cin>>b3[i].Cost_Book;
//		cout<<"Please enter auther"<<endl;
//		cin>>b3[i].book_auth;
//		
//	}
//	
//	for (int i=0;i<=1;i++){
//		cout<<" book name"<<endl;
//		cout<<b3[i].book_name;
//		cout<<" cost"<<endl;
//		cout<<b3[i].Cost_Book<<endl;
//		cout<<" auther"<<endl;
//		cout<<b3[i].book_auth<<endl;
//		
//	}
//	
getche();

}
 here.
This:

 
    void dis_books(b1[no_books]);

should be this:

 
    void dis_books(book b[], int no_books);


Note that you need to use the type (book) and no_books needs to be a separate parameter. Also, you should leave the [] empty,

BTW, your abbrevs aren't gaining you anything. mnu and dis just make your code harder to read.
Last edited on
Also, at line 75, an | is the bitwise OR-operator. If you want to check if neither of your numbers where be entered, you need to write: if( choice!=1 && choice!=2 &&...
Registered users can post here. Sign in or register to post.