hospital management system

Hi so basically i have a project where i have to create a management system of a hospital. it is not complete and i am still working on . so basically in the switch above there are 2 options 1 for adding new doctors to file and 2 for showing all the doctors that are currently there. what i basically want is that all the information about the doctors that i have entered in should be shown when i press 2.

I made some corrections to the best of my knowledge but if you could help me out once more i will really appreciate it. I have also put out my entire code.



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
#include<stdio.h>    
#include<iostream> 
#include<fstream> 
#include<string> 
using namespace std; 
	

void doctordetails(){
	char name[50],field[50];
	int num,age;
	fstream doctor;
	int doctordetail;
		cout<<"\t***************  Doctor Details  *****************\n\n\n";
		cout<<"1. Add New Doctor\n\n2. View All Doctors.\n\n";
		cin>>doctordetail;
		system ("cls");
		switch(doctordetail){
		case 1:
		ofstream doctor;
		doctor.open("doctordetails.txt");
		cin.sync();
		cout<<"\nEnter The Doctor Name = ";
		cin.getline(name,50);
		cout<<"\nEnter the Doctors Field = ";
		cin.getline(field,50);
		cout<<"\nEnter Age = ";
		cin>>age;
		cout<<"\nEnter Experience(in years) = ";
		cin>>num;
		system("cls");
		cout<<"\n\nYour Entry Has been saved ";

		break;

				
		}
}
void patientdetails(){
		cout<<"\t***************  Patient Details  *****************\n\n\n";
		cout<<"1. Add New Patient\n\n2. View Patient Details.";
}
void hospitalservices(){
		cout<<"\t***************  Hospital Services  *****************\n\n\n";
		cout<<"1. Add New Hospital Services\n\n2. View Hospital Services.";
}
int main(){
	int choice1, choice2;
	cout<<"\t***************  Hospital Managment System  *****************\n\n\n";
	cout<<"\n\nPlease Choose from the Menu\n\n1. Admin\n\n2. Doctor\n\n3. Patient\n\n";
	cin>>choice1;
	system("cls");
	if(choice1==1){	
		cout<<"\t***************  Admin  *****************\n\n\n";
		cout<<"1. Doctor Details\n\n2. Patient Details\n\n3. Hospital Services\n\n";
		cin>>choice2;
		system("cls");
		switch(choice2)
		{
		case 1: 
		doctordetails();
		break;
		case 2: 
		patientdetails();
		break;
		case 3: 
		hospitalservices();
		break;
		default:
			cout<<"Error!! Please Choose from the menu";
		break;
		}

		}		
 return 0;
}
How many threads there will be on the same "hospital"? (Double-posting will not help.)
http://www.cplusplus.com/forum/beginner/271215/
http://www.cplusplus.com/forum/beginner/271218/

You don't seem to store the doctors anywhere, neither in memory nor in file. You can't show what you don't have.


I have to ask about your code:
1
2
#include<stdio.h>  
#include<string> 

What is the purpose of these two lines?


I would define a type that holds data for one doctor and then store objects of that type in a std::vector.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <vector>

struct Doctor {
  // data members
};


// used in
std::vector<Doctor> doctors;
Doctor doctor;
// set members for a doctor
doctors.push_back( doctor ); // add doctor to doctors

// show all doctors
for ( auto d : doctors ) {
  // print doctor d
}
Topic archived. No new replies allowed.