Question

// C code // If you modify any of the given code, the return types, or...

// C code
// If you modify any of the given code, the return types, or the parameters, you risk getting compile error.
// Yyou are not allowed to modify main ().
// You can use string library functions.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#pragma warning(disable: 4996) // for Visual Studio

#define MAX_NAME 30

// global linked list 'list' contains the list of patients
struct patientList {
   struct patient *patient;
   struct patientList *next;
} *list = NULL;               // currently empty list

// structure "patient" contains the patient's name, room number and linked list of doctors
struct patient {
   char name[MAX_NAME];
   unsigned int roomNumber;
   struct doctor *doctors;       // linked list 'doctors' contains names of doctors
};

// structure 'doctor' contains doctor's name
struct doctor {
   char name[MAX_NAME];
   struct doctor *next;
};

// forward declaration of functions (already implmented)
void flushStdIn();
void executeAction(char);

// functions that need implementation:
void addPatient(char* patientNameInput, unsigned int roomNumInput);
struct patient* searchPatient(char* patientNameInput);
void displayList(struct patientList* tempList);
void addDoctor(char* patientNameInput, char* doctorNameInput);
void removePatient(char* patientNameInput);  
char* lastDoctor(char* patientNameInput);
struct patientList* patientsOnThisFloor(unsigned int floorNumber);
void deleteList(struct patientList* pList);


int main()
{
   char selection = 'a';       // initialized to a dummy value
   do
   {
       printf("\nCSE220 Project 5\n");
       printf("Please enter your selection:\n");
       printf("\t a: add a new patient to the list\n");
       printf("\t d: display patient list\n");
       printf("\t c: add a doctor of a patient\n");      
       printf("\t r: remove a patient\n");
       printf("\t l: display last added doctor of a patient\n");
       printf("\t b: display patients on a floor\n");
       printf("\t q: quit\n");

       selection = getchar();
       flushStdIn();
       executeAction(selection);
   } while (selection != 'q');

   return 0;
}

// flush out leftover '\n' characters
void flushStdIn()
{
   char c;
   do c = getchar();
   while (c != '\n' && c != EOF);
}

// Ask for details from user for the given selection and perform that action
void executeAction(char c)
{
   char patientNameInput[MAX_NAME], doctorNameInput[MAX_NAME];
   unsigned int roomNumInput, floorNumber;
   struct patient* searchResult = NULL;
   int n;

   switch (c)
   {
   case 'a':   // add patient
               // input patient details from user
       printf("\nPlease enter patient's name: ");
       fgets(patientNameInput, sizeof(patientNameInput), stdin);
       patientNameInput[strlen(patientNameInput) - 1] = '\0';   // discard the trailing '\n' char
       printf("Please enter room number: ");
       scanf("%d", &roomNumInput);
       flushStdIn();

       if (searchPatient(patientNameInput) == NULL)                  
       {
           addPatient(patientNameInput, roomNumInput);
           printf("\nPatient successfully added to the list!\n");
       }
       else
           printf("\nThat patient is already on the list!\n");
       break;

   case 'd':       // display the list
       displayList(list);
       break;

   case 'c':       // add doctor
       printf("\nPlease enter patient's name: ");
       fgets(patientNameInput, sizeof(patientNameInput), stdin);
       patientNameInput[strlen(patientNameInput) - 1] = '\0';   // discard the trailing '\n' char

       if (searchPatient(patientNameInput) == NULL)                  
           printf("\nPatient name does not exist or the list is empty! \n\n");
       else
       {
           printf("\nPlease enter doctor's name: ");
           fgets(doctorNameInput, sizeof(doctorNameInput), stdin);
           doctorNameInput[strlen(doctorNameInput) - 1] = '\0';   // discard the trailing '\n' char

           addDoctor(patientNameInput, doctorNameInput);
           printf("\nDoctor added! \n\n");
       }
       break;

   case 'r':       // remove patient
       printf("\nPlease enter patient's name: ");
       fgets(patientNameInput, sizeof(patientNameInput), stdin);
       patientNameInput[strlen(patientNameInput) - 1] = '\0';   // discard the trailing '\n' char

       if (searchPatient(patientNameInput) == NULL)              
           printf("\nPatient name does not exist or the list is empty! \n\n");
       else
       {
           removePatient(patientNameInput);
           printf("\nPatient successfully removed from the list! \n\n");
       }
       break;

   case 'l':       // last doctor
       printf("\nPlease enter patient's name: ");
       fgets(patientNameInput, sizeof(patientNameInput), stdin);
       patientNameInput[strlen(patientNameInput) - 1] = '\0';   // discard the trailing '\n' char

       if (searchPatient(patientNameInput) == NULL)              
           printf("\nPatient name does not exist or the list is empty! \n\n");
       else
       {
           printf("\nlast doctor added: %s\n\n", lastDoctor(patientNameInput));
       }
       break;

   case 'b':       // patients on a floor
       printf("Please enter floor number: ");
       scanf("%d", &floorNumber);
       flushStdIn();
       struct patientList* result = patientsOnThisFloor(floorNumber);
       displayList(result);
       deleteList(result);
       break;

   case 'q':       // quit
       deleteList(list);
       break;

   default: printf("%c is invalid input!\n", c);
   }
}

// addPatient
// This function is used to insert a new patient in the linked list. You must insert the new patient to the head of linked list 'list'.
// Hint: In this question, no doctors means NULL doctors.

void addPatient(char* patientNameInput, unsigned int roomNumInput)
{

}

// searchPatient
// This function searches the 'list' to check if the given patient exists in the list. Search by patient name.
// If it exists then return that 'patient' node of the list. Notice the return type of this function.
// If the patient does not exist in the list, then return NULL.

struct patient* searchPatient(char* patientNameInput)
{
   struct patientList* tempList = list;           // work on a copy of 'list'
   // enter code here

   return NULL;       // edit this line if needed
}

// displayList
// This function displays every detail(name, room number, doctors) of each patient.
// Parse through the linked list 'tempList' passed as parameter and print the patient details one after the other.
// See expected output screenshots in homework question file.

void displayList(struct patientList* tempList)
{

}

// addDoctor
// This function adds doctor's name to a patient node.
// Parse the list to locate the patient and add the doctor to that patient's 'doctors' linked list. No need to check if the patient name exists on the list. That is done in executeAction().
// You can assume that the same doctor name does not exist. So no need to check for existing doctor names.
// You are free to add new doctor to head or tail of 'doctors' list. (Sample solution has doctor added to the tail of 'doctors' list.)

void addDoctor(char* patientNameInput, char* doctorNameInput)
{
   struct patientList* tempList = list;       // work on a copy of 'list'
   // enter code here

}

// removePatient
// This function removes a patient from the list.
// Parse the list to locate the patient and delete that 'patient' node.
// You need not check if the patient exists because that is done in executeAction()
// NOTE: You need to remove the doctors too, if any.

void removePatient(char* patientNameInput)
{
   struct patientList* tempList = list;   // work on a copy of 'list'
   // enter code here

}

// lastDoctor
// This function returns the name of the last (most recently) added doctor of a patient.
// Parse the list to locate the patient. No need to check if the patient name exists in the list. That is done in executeAction().
// Then parse the doctor names to return the most recently added doctor.
// NOTE: Last doctor does not necessarily mean the tail of 'doctors' list. It means the most recently added doctor.
// If you are adding doctor to the head of the list in addDoctor(), then you should return that doctor name accordingly.

char* lastDoctor(char* patientNameInput)
{
  
   struct patientList* tempList = list;       // work on a copy of 'list'
   // enter code here

   return NULL;   // edit this line if needed
}


// patientsOnThisFloor
// This function is used to construct a new linked list 'resultList' from the global linked list 'list'.
// The returned list should contain the patients whose floor number matches with the input parameter 'floorNumber'.
// Input the room number as a 3-digit number and first digit is the floor number. Eg-room 235 means floor 2.
// No sorting is required for this list.
// The list that you return will be printed by displayList() and then cleaned up by the deleteDatabase() function. This is done in case 'b' of executeAction().
// Note that the returned list will need to contain doctor information too.
// This function should NOT modify the global linked list 'list'.
struct patientList* patientsOnThisFloor(unsigned int floorNumber)
{
   struct patientList* tempList = list;   // work on a copy of 'list'
   struct patientList* resultList = NULL;
   // enter code here
  
   return resultList;   // result list contains the search result
}
// deleteList
// Delete all nodes and linked lists inside the passed argument 'pList'
// This fucntion is used to delete the linked list before exiting the program.

void deleteList(struct patientList* pList)
{

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Below is complete code. Let me know if you have any problem or doubt. Thank you.

====================================================================

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#pragma warning(disable: 4996) // for Visual Studio

#define MAX_NAME 30

// global linked list 'list' contains the list of patients
struct patientList {
    struct patient* patient;
    struct patientList* next;
} *list = NULL;               // currently empty list

// structure "patient" contains the patient's name, room number and linked list of doctors
struct patient {
    char name[MAX_NAME];
    unsigned int roomNumber;
    struct doctor* doctors;       // linked list 'doctors' contains names of doctors
};

// structure 'doctor' contains doctor's name
struct doctor {
    char name[MAX_NAME];
    struct doctor* next;
};

// forward declaration of functions (already implmented)
void flushStdIn();
void executeAction(char);

// functions that need implementation:
void addPatient(char* patientNameInput, unsigned int roomNumInput);
struct patient* searchPatient(char* patientNameInput);
void displayList(struct patientList* tempList);
void addDoctor(char* patientNameInput, char* doctorNameInput);
void removePatient(char* patientNameInput);
char* lastDoctor(char* patientNameInput);
struct patientList* patientsOnThisFloor(unsigned int floorNumber);
void deleteList(struct patientList* pList);


int main()
{
    char selection = 'a';       // initialized to a dummy value
    do
    {
        printf("\nCSE220 Project 5\n");
        printf("Please enter your selection:\n");
        printf("\t a: add a new patient to the list\n");
        printf("\t d: display patient list\n");
        printf("\t c: add a doctor of a patient\n");
        printf("\t r: remove a patient\n");
        printf("\t l: display last added doctor of a patient\n");
        printf("\t b: display patients on a floor\n");
        printf("\t q: quit\n");

        selection = getchar();
        flushStdIn();
        executeAction(selection);
    } while (selection != 'q');

    return 0;
}

// flush out leftover '\n' characters
void flushStdIn()
{
    char c;
    do c = getchar();
    while (c != '\n' && c != EOF);
}

// Ask for details from user for the given selection and perform that action
void executeAction(char c)
{
    char patientNameInput[MAX_NAME], doctorNameInput[MAX_NAME];
    unsigned int roomNumInput, floorNumber;
    struct patient* searchResult = NULL;
    int n;

    switch (c)
    {
    case 'a':   // add patient
                // input patient details from user
        printf("\nPlease enter patient's name: ");
        fgets(patientNameInput, sizeof(patientNameInput), stdin);
        patientNameInput[strlen(patientNameInput) - 1] = '\0';   // discard the trailing '\n' char
        printf("Please enter room number: ");
        scanf("%d", &roomNumInput);
        flushStdIn();

        if (searchPatient(patientNameInput) == NULL)
        {
            addPatient(patientNameInput, roomNumInput);
            printf("\nPatient successfully added to the list!\n");
        }
        else
            printf("\nThat patient is already on the list!\n");
        break;

    case 'd':       // display the list
        displayList(list);
        break;

    case 'c':       // add doctor
        printf("\nPlease enter patient's name: ");
        fgets(patientNameInput, sizeof(patientNameInput), stdin);
        patientNameInput[strlen(patientNameInput) - 1] = '\0';   // discard the trailing '\n' char

        if (searchPatient(patientNameInput) == NULL)
            printf("\nPatient name does not exist or the list is empty! \n\n");
        else
        {
            printf("\nPlease enter doctor's name: ");
            fgets(doctorNameInput, sizeof(doctorNameInput), stdin);
            doctorNameInput[strlen(doctorNameInput) - 1] = '\0';   // discard the trailing '\n' char

            addDoctor(patientNameInput, doctorNameInput);
            printf("\nDoctor added! \n\n");
        }
        break;

    case 'r':       // remove patient
        printf("\nPlease enter patient's name: ");
        fgets(patientNameInput, sizeof(patientNameInput), stdin);
        patientNameInput[strlen(patientNameInput) - 1] = '\0';   // discard the trailing '\n' char

        if (searchPatient(patientNameInput) == NULL)
            printf("\nPatient name does not exist or the list is empty! \n\n");
        else
        {
            removePatient(patientNameInput);
            printf("\nPatient successfully removed from the list! \n\n");
        }
        break;

    case 'l':       // last doctor
        printf("\nPlease enter patient's name: ");
        fgets(patientNameInput, sizeof(patientNameInput), stdin);
        patientNameInput[strlen(patientNameInput) - 1] = '\0';   // discard the trailing '\n' char

        if (searchPatient(patientNameInput) == NULL)
            printf("\nPatient name does not exist or the list is empty! \n\n");
        else
        {
            printf("\nlast doctor added: %s\n\n", lastDoctor(patientNameInput));
        }
        break;

    case 'b':       // patients on a floor
        printf("Please enter floor number: ");
        scanf("%d", &floorNumber);
        flushStdIn();
        struct patientList* result = patientsOnThisFloor(floorNumber);
        displayList(result);
        deleteList(result);
        break;

    case 'q':       // quit
        deleteList(list);
        break;

    default: printf("%c is invalid input!\n", c);
    }
}

// addPatient
// This function is used to insert a new patient in the linked list. You must insert the new patient to the head of linked list 'list'.
// Hint: In this question, no doctors means NULL doctors.

void addPatient(char* patientNameInput, unsigned int roomNumInput)
{
    // create a patient struct
    struct patient* p = (struct patient*)malloc(sizeof(struct patient));
    // assign name of patient
    strcpy(p->name, patientNameInput);
    p->roomNumber = roomNumInput;
    p->doctors = NULL; // initialy no doctors assign
    // check if list is empty
    if (list == NULL) {
        // initialize list
        list = (struct patientList*)malloc(sizeof(struct patientList));
        // assign first patient
        list->patient = p;
        list->next = NULL;
    }
    else {
        // create new node
        struct patientList* newlist = (struct patientList*)malloc(sizeof(struct patientList));
        // add patient at head of list
        newlist->patient = p;
        newlist->next = list;
        // update head
        list = newlist;
    }
}

// searchPatient
// This function searches the 'list' to check if the given patient exists in the list. Search by patient name.
// If it exists then return that 'patient' node of the list. Notice the return type of this function.
// If the patient does not exist in the list, then return NULL.

struct patient* searchPatient(char* patientNameInput)
{
    struct patientList* tempList = list;           // work on a copy of 'list'
    // search the list
    while (tempList != NULL) {
        // check patient name
        if (strcmp(tempList->patient->name, patientNameInput) == 0) {
            // patient with given name found return the patient
            return tempList->patient;
        }
        // move to next patient
        tempList = tempList->next;
    }
    return NULL;       // edit this line if needed
}

// displayList
// This function displays every detail(name, room number, doctors) of each patient.
// Parse through the linked list 'tempList' passed as parameter and print the patient details one after the other.
// See expected output screenshots in homework question file.

void displayList(struct patientList* tempList)
{
    // print every patient in list
    while (tempList != NULL) {
        // print patient details
        printf("Patient name: %s\n", tempList->patient->name);
        printf("Room number: %d\n", tempList->patient->roomNumber);
        printf("Doctors: \n");
        // print doctors
        struct doctor* doctors = tempList->patient->doctors;
        while (doctors != NULL) {
            printf("%s\n", doctors->name);
            doctors = doctors->next;
        }
        // move to next patient
        tempList = tempList->next;
    }
}

// addDoctor
// This function adds doctor's name to a patient node.
// Parse the list to locate the patient and add the doctor to that patient's 'doctors' linked list. No need to check if the patient name exists on the list. That is done in executeAction().
// You can assume that the same doctor name does not exist. So no need to check for existing doctor names.
// You are free to add new doctor to head or tail of 'doctors' list. (Sample solution has doctor added to the tail of 'doctors' list.)

void addDoctor(char* patientNameInput, char* doctorNameInput)
{
    struct patientList* tempList = list;       // work on a copy of 'list'
    // create a doctor
    struct doctor* newdoctor = (struct doctor*)malloc(sizeof(struct doctor));
    strcpy(newdoctor->name, doctorNameInput);
    newdoctor->next = NULL;
    // get the patient
    struct patient* p = searchPatient(patientNameInput);
    // add doctor at tail of list
    if (p->doctors == NULL) {
        // assign first doctor
        p->doctors = newdoctor;
    }
    else {
        // move to last doctor in list
        struct doctor* doclist = p->doctors;
        while (doclist->next != NULL) {
            doclist = doclist->next;
        }
        // add new doctor at tail
        doclist->next = newdoctor;
    }
}

// removePatient
// This function removes a patient from the list.
// Parse the list to locate the patient and delete that 'patient' node.
// You need not check if the patient exists because that is done in executeAction()
// NOTE: You need to remove the doctors too, if any.

void removePatient(char* patientNameInput)
{
    struct patientList* tempList = list;   // work on a copy of 'list'
    // check if the first patient is need to be removed
    if (strcmp(list->patient, patientNameInput) == 0) {
        struct patient* temp = list->patient;
        // move head to next node
        list = list->next;
        // remove all doctors
        while (temp->doctors != NULL) {
            struct doctor* doc = temp->doctors;
            // move to next doctor
            temp->doctors = temp->doctors->next;
            free(doc);
        }
        // remove the patient
        free(temp);
    }
    else {
        // find the patient to be removed
        while (tempList->next != NULL) {
            if (strcmp(tempList->next->patient->name, patientNameInput) == 0) {
                // remove the patient from list
                struct patient* temp = tempList->next->patient;
                // remove the link
                tempList->next = tempList->next->next;
                // remove all doctors
                while (temp->doctors != NULL) {
                    struct doctor* doc = temp->doctors;
                    // move to next doctor
                    temp->doctors = temp->doctors->next;
                    free(doc);
                }
                free(temp);
                break; // remove only one patient with given name if multiple patient with same name exist
            }
        }
    }
}

// lastDoctor
// This function returns the name of the last (most recently) added doctor of a patient.
// Parse the list to locate the patient. No need to check if the patient name exists in the list. That is done in executeAction().
// Then parse the doctor names to return the most recently added doctor.
// NOTE: Last doctor does not necessarily mean the tail of 'doctors' list. It means the most recently added doctor.
// If you are adding doctor to the head of the list in addDoctor(), then you should return that doctor name accordingly.

char* lastDoctor(char* patientNameInput)
{

    struct patientList* tempList = list;       // work on a copy of 'list'
    // get the patient
    struct patient* p = searchPatient(patientNameInput);
    if (p->doctors == NULL) {
        return NULL;   // no doctor assigned to patient
    }
    else {
        // get last assigned doctor
        struct doctor* docs = p->doctors;
        while (docs->next != NULL) {
            docs = docs->next;
        }
        // return doctor's name
        return docs->name;
    }
}


// patientsOnThisFloor
// This function is used to construct a new linked list 'resultList' from the global linked list 'list'.
// The returned list should contain the patients whose floor number matches with the input parameter 'floorNumber'.
// Input the room number as a 3-digit number and first digit is the floor number. Eg-room 235 means floor 2.
// No sorting is required for this list.
// The list that you return will be printed by displayList() and then cleaned up by the deleteDatabase() function. This is done in case 'b' of executeAction().
// Note that the returned list will need to contain doctor information too.
// This function should NOT modify the global linked list 'list'.
struct patientList* patientsOnThisFloor(unsigned int floorNumber)
{
    struct patientList* tempList = list;   // work on a copy of 'list'
    struct patientList* resultList = NULL;
    // create poinert to add patients
    struct patientList* resultptr = resultList;
    // find all the patient in given floor
    while (tempList != NULL) {
        if (tempList->patient->roomNumber / 100 == floorNumber) {
            // copy the patient data
            struct patient* copy = (struct patient*)malloc(sizeof(struct patient));
            copy->roomNumber = tempList->patient->roomNumber;
            strcpy(copy->name, tempList->patient->name);
            copy->doctors = NULL;
            // copy doctors
            if (tempList->patient->doctors != NULL) {
                copy->doctors = (struct doctor*)malloc(sizeof(struct doctor));
                strcpy(copy->doctors->name, tempList->patient->doctors->name);
                copy->doctors->next = NULL;
                // copy remaining doctors
                struct doctor* copyfrom = tempList->patient->doctors;
                struct doctor* copyto = copy->doctors;
                while (copyfrom->next != NULL) {
                    copyto->next = (struct doctor*)malloc(sizeof(struct doctor));
                    strcpy(copyto->next->name, copyfrom->next->name);
                    // move to next node
                    copyto = copyto->next;
                    copyfrom = copyfrom->next;
                    copyto->next = NULL;
                }
            }

            // check is result list is empty
            if (resultList == NULL) {
                // initialize list
                resultList = (struct patientList*)malloc(sizeof(struct patientList));
                // add first patient from floor
                resultList->patient = copy;
                resultList->next = NULL;
                // reset pointer
                resultptr = resultList;
            }
            else {
                // add patient to result list
                resultptr->next = copy;
                // move to next pointer
                resultptr = resultptr->next;
                resultptr->next = NULL;
            }
        }
        tempList = tempList->next;
    }

    return resultList;   // result list contains the search result
}

// deleteList
// Delete all nodes and linked lists inside the passed argument 'pList'
// This fucntion is used to delete the linked list before exiting the program.

void deleteList(struct patientList* pList)
{
    // delete all nodes
    while (pList != NULL) {
        struct patient* temp = pList->patient;
        // remove all doctors
        while (temp->doctors != NULL) {
            struct doctor* doc = temp->doctors;
            // move to next doctor
            temp->doctors = temp->doctors->next;
            free(doc);
        }
        pList = pList->next;
        free(temp);
    }
}

CX C:\Users\ASUS FX505\source\repos\Patient data\Debug\Patient data.exe - O X CSE220 Project 5 Please enter your selection: a

Add a comment
Know the answer?
Add Answer to:
// C code // If you modify any of the given code, the return types, or...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • // CSE240 Spring 2019 HW 7 & 8 // Write your name here // Write the...

    // CSE240 Spring 2019 HW 7 & 8 // Write your name here // Write the compiler used: Visual studio or gcc // READ BEFORE YOU START: // You are given a partially completed program that creates a linked list of patient information. // The global linked list 'list' is a list of patients with each node being struct 'patientList'. // 'patientList' consists of struct 'patient' which has: patient name, room number, and a linked list of 'doctors'. // The...

  • ASSIGNMENT DUE DATE GOT PUSHED BACK TO LATE THIS WEEK. PLEASE READ COMMENTS AND CODE BEFORE...

    ASSIGNMENT DUE DATE GOT PUSHED BACK TO LATE THIS WEEK. PLEASE READ COMMENTS AND CODE BEFORE ANSWERING CODING SECTIONS HW07 #Q1-Q5 HW08 #Q1-Q2 // READ BEFORE YOU START: // Please read the given Word document for the project description with an illustrartive diagram. // You are given a partially completed program that creates a list of students for a school. // Each student has the corresponding information: name, standard, and a linked list of absents. // Please read the instructions...

  • // Write the compiler used: Visual studio // READ BEFORE YOU START: // You are given...

    // Write the compiler used: Visual studio // READ BEFORE YOU START: // You are given a partially completed program that creates a list of patients, like patients' record. // Each record has this information: patient's name, doctor's name, critical level of patient, room number. // The struct 'patientRecord' holds information of one patient. Critical level is enum type. // An array of structs called 'list' is made to hold the list of patients. // To begin, you should trace...

  • // READ BEFORE YOU START: // You are given a partially completed program that creates a...

    // READ BEFORE YOU START: // You are given a partially completed program that creates a list of students for a school. // Each student has the corresponding information: name, gender, class, standard, and roll_number. // To begin, you should trace through the given code and understand how it works. // Please read the instructions above each required function and follow the directions carefully. // If you modify any of the given code, the return types, or the parameters, you...

  • Need help for C program. Thx #include <stdio.h> #include <string.h> #include <ctype.h> // READ BEFORE YOU...

    Need help for C program. Thx #include <stdio.h> #include <string.h> #include <ctype.h> // READ BEFORE YOU START: // This homework is built on homework 06. The given program is an updated version of hw06 solution. It begins by displaying a menu to the user // with the add() function from the last homework, as well as some new options: add an actor/actress to a movie, display a list of movies for // an actor/actress, delete all movies, display all movies,...

  • Hello! I'm posting this program that is partially completed if someone can help me out, I...

    Hello! I'm posting this program that is partially completed if someone can help me out, I will give you a good rating! Thanks, // You are given a partially completed program that creates a list of employees, like employees' record. // Each record has this information: employee's name, supervisors's name, department of the employee, room number. // The struct 'employeeRecord' holds information of one employee. Department is enum type. // An array of structs called 'list' is made to hold...

  • C program help #include #include #include void PrintName(char firstname[16], char lastname[16]); int main () { char...

    C program help #include #include #include void PrintName(char firstname[16], char lastname[16]); int main () { char firstname[16]; char lastname[16]; printf("please enter your first name:"); scanf("%s",firstname); printf("please enter your last name:"); scanf("%s",lastname); PrintName(firstname,lastname); return 0; } void PrintName(char firstname[16], char lastname[16]){ char fullname[34]; *fullname=*firstname+*lastname; (char*) malloc (sizeof (*fullname)); if (strlen(firstname) > 16||strlen(lastname)>16||strlen(fullname)>16) fflush(stdin); else printf(" the full name is %s %s \n",firstname,lastname); printf(" the full name is-> %s",fullname);/*why is one not run*/ return 0; }

  • ****Using C and only C**** I have some C code that has the function addRecord, to...

    ****Using C and only C**** I have some C code that has the function addRecord, to add a record to a linked list of records. However, when I run it, the program exits after asking the user to input the address. See picture below: Here is my code: #include<stdio.h> #include<stdlib.h> struct record { int accountno; char name[25]; char address[80]; struct record* next; }; void addRecord(struct record* newRecord) //Function For Adding Record at last in a SinglyLinkedList { struct record *current,*start,*temp;...

  • Please help modify my C program to be able to answer these questions, it seems the...

    Please help modify my C program to be able to answer these questions, it seems the spacing and some functions arn't working as planeed. Please do NOT copy and paste other work as the answer, I need my source code to be modified. Source code: #include <stdio.h> #include <string.h> #include <ctype.h> #include <stdlib.h> int main(void) { char title[50]; char col1[50]; char col2[50]; int point[50]; char names[50][50]; printf("Enter a title for the data:\n"); fgets (title, 50, stdin); printf("You entered: %s\n", title);...

  • URGENT. Need help editing some C code. I have done most of the code it just...

    URGENT. Need help editing some C code. I have done most of the code it just needs the following added: takes an input file name from the command line; opens that file if possible; declares a C struct with three variables; these will have data types that correspond to the data types read from the file (i.e. string, int, float); declares an array of C structs (i.e. the same struct type declared in point c); reads a record from the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT