Write a function in C++ to write N number of record in binary files ‘hospital.dat’ and
Search for a room number (room no) given by the user in an existing binary files ‘hospital.dat’.

No one here is going to write your program for you. Here are some basic steps needed to complete your assignment.

Step 1: create a structure that contains all the information you need to store in the file.

Step 2: populate the structure with the data

Step 3: using std::ofstream open a file for binary writing

Step 4: call std::ofstream's write() function to write out the structure in binary form. It will write the structure all in one big chunck of data exactly as it appears in memory. repeat this as often as necessary to write out all the structures.

Step 5: close the output file that was opened in Step 3.

Step 6: To read the file, open an std::ifstream for reading in binary mode

Step 7: Call std::ifstream's read() function to read the structure(s) written in steps 3-5.