Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2.  
  3. #include<stdio.h>
  4. #include<malloc.h>
  5. #include<string.h>
  6.  
  7. struct Disease {
  8. char* name;
  9. bool cured;
  10. Disease* next;
  11. }Disease;
  12.  
  13. typedef struct Patient {
  14. char* name;
  15. int age;
  16. struct Disease* diseases;
  17. struct Patient* next;
  18. }Patient;
  19.  
  20.  
  21. void curedDisease(struct Patient* patients,char* patientName, char* diseaseName) {
  22. struct Patient* temp = patients;
  23. while (temp != NULL)
  24. {
  25. if (!strcmp(temp->name, patientName)) {
  26. struct Disease* temp1 = temp->diseases;
  27. while (temp1 != NULL) {
  28. if (!strcmp(temp1->name, diseaseName)) {
  29. temp1->cured = true;
  30. break;
  31. }
  32. temp1 = temp1->next;
  33. }
  34. }
  35. temp = temp->next;
  36. }
  37. }
  38.  
  39. void freeAllocation(struct Patient* patients) {
  40. struct Patient* temp = patients;
  41. struct Patient* head = patients;
  42. while (temp != NULL)
  43. {
  44. struct Disease* temp1 = temp->diseases;
  45. struct Disease* head1 = temp->diseases;
  46.  
  47. while (temp1 != NULL) {
  48.  
  49. temp1 = temp1->next;
  50. free(head1);
  51. head1 = temp1;
  52. }
  53. temp = temp->next;
  54. free(head);
  55. head = temp;
  56. }
  57. }
  58.  
  59. int main() {
  60.  
  61.  
  62.  
  63. return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement