Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please I\'m a beginner and I don\'t know much about c++, please Ineed help on ch

ID: 3613162 • Letter: P

Question

Please I'm a beginner and I don't know much about c++, please Ineed help on changing this c code to c++ code. Thanks.

This is the text file.

HAC
Maury Walker 46
James Christopher 47


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define FOUND 4

#define MAX_DOCS 2
#define MAX_OPER 5
#define MAX_PATIENTS 3
#define INITIAL_DOUBLES 0.0
#define INITIAL_INTS 0
#define INITIALCASH_REG 0.00

struct patient
{
        char firstname[20];
        char lastname[20];
        int id;
        double savingacct;
        int operationid;
        int chosendoc;
};
struct doctor
{
        char firstname[20];
        char lastname[20];
        int id;
        double checkacctbal;
        int countopera;
        double clinicsal;
        double doc_charges;
};
struct clinic
{
        char clinicname[20];
        char parentcomp[20];
        intoperations[MAX_OPER];
        doubledocsalaries[MAX_DOCS];
        struct doctor*doc[MAX_DOCS];
        struct patient*pat[MAX_PATIENTS];
};

void storeclinicname(FILE *notefile, char *c_name);
void allocdoctor_mem(FILE *notefile, struct clinic *xhosp);
void storedoctor_info(FILE *notefile, struct clinic *xhosp);
void printlist(struct clinic *xhosp);

int main(void)
{
          FILE*file;
         int m;
         struct clinichosp;
          structpatient *xpter;

       file = fopen("hw4.dat","r");
       if(file == NULL)
        {
           printf("hw4.dat unavailable ");
            exit(0);
         }

        storeclinicname(file,hosp.clinicname);
        allocdoctor_mem(file,&hosp);
        storedoctor_info(file,&hosp);
       printlist(&hosp);
        fclose(file);
}
void storeclinicname(FILE *notefile, char *c_name)
{

        fscanf(notefile, "%s",c_name);
        printf(" %s is thename of the new clinic. ", c_name);
}
void allocdoctor_mem(FILE *notefile, struct clinic *xhosp)
{
        int index;

       for(index=0;index<MAX_DOCS;index++)
          xhosp->doc[index] = (struct doctor *) malloc(1 * sizeof(structdoctor));
}
void storedoctor_info(FILE *notefile, struct clinic *xhosp)
{
        int index;

        for(index=0;index<MAX_DOCS; index++)
            fscanf(notefile, "%s %s %d", xhosp->doc[index]->firstname,xhosp->doc[index]->lastname,&(xhosp->doc[index]->id));
}
void printlist(struct clinic *xhosp)
{
        int index;

          printf(" This is the doctorsinformations -------------------------------- ");
          for(index=0;index<MAX_DOCS; index++)
               printf("%s %s %d ",xhosp->doc[index]->firstname,xhosp->doc[index]->lastname,xhosp->doc[index]->id);
}


Explanation / Answer

#include#include#include#define FOUND 4using namespace std;#define MAX_DOCS 2#define MAX_OPER 5#define MAX_PATIENTS 3#define INITIAL_DOUBLES 0.0#define INITIAL_INTS 0#define INITIALCASH_REG 0.00struct patient{char firstname[20];char lastname[20];int id;double savingacct;int operationid;int chosendoc;};struct doctor{char firstname[20];char lastname[20];int id;double checkacctbal;int countopera;double clinicsal;double doc_charges;};struct clinic{char clinicname[20];char parentcomp[20];int operations[MAX_OPER];double docsalaries[MAX_DOCS];struct doctor *doc[MAX_DOCS];struct patient *pat[MAX_PATIENTS];};void storeclinicname(FILE *notefile, char *c_name);void allocdoctor_mem(FILE *notefile, struct clinic *xhosp);void storedoctor_info(FILE *notefile, struct clinic *xhosp);void printlist(struct clinic *xhosp);int main(void){FILE *file;int m;struct clinic hosp;struct patient *xpter;file = fopen("hw4.dat", "r");if(file == NULL){cout