Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include<stdio.h>
- #include<malloc.h>
- #include<string.h>
- struct Disease {
- char* name;
- bool cured;
- Disease* next;
- }Disease;
- typedef struct Patient {
- char* name;
- int age;
- struct Disease* diseases;
- struct Patient* next;
- }Patient;
- void curedDisease(struct Patient* patients,char* patientName, char* diseaseName) {
- struct Patient* temp = patients;
- while (temp != NULL)
- {
- if (!strcmp(temp->name, patientName)) {
- struct Disease* temp1 = temp->diseases;
- while (temp1 != NULL) {
- if (!strcmp(temp1->name, diseaseName)) {
- temp1->cured = true;
- break;
- }
- temp1 = temp1->next;
- }
- }
- temp = temp->next;
- }
- }
- void freeAllocation(struct Patient* patients) {
- struct Patient* temp = patients;
- struct Patient* head = patients;
- while (temp != NULL)
- {
- struct Disease* temp1 = temp->diseases;
- struct Disease* head1 = temp->diseases;
- while (temp1 != NULL) {
- temp1 = temp1->next;
- free(head1);
- head1 = temp1;
- }
- temp = temp->next;
- free(head);
- head = temp;
- }
- }
- int main() {
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement