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.
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
}