How to free chain link consisting of this structure?

typedef struct tpatient
{
char* name;
char* surname;
TADDRESS* address;
char* id;
int age;
char gender;
BLOOD_TYPE blood;
struct tpatient *next;
} TPATIENT;
1
2
3
4
5
6
7
8
Create a current and temp pointer. 
Set current pointer to the first occurrance. 
while (current is not null)
{   set temp pointet to next
    *
    delete current 
    set current to temp pointer 
}

* = If name, surname, address, id were allocated dynamically, be sure and delete those too.
Last edited on
Topic archived. No new replies allowed.