B
bugzilla
hi, there,
Please help me to figure out this problem. In the following code
segment, how to free the momory allocated to "head" in {STULST*
CreateList()} in main() function? thanks
///////////////////////////////////////////
#include <stdio.h>
typedef struct
{
int num;
float score;
}STUDENT;
typedef struct STULST
{
STUDENT *stu;
struct STULST* next;
}STULST;
STULST* CreateList()
{
STULST *head;
head=(STULST *)malloc(sizeof(STULST));
head->stu=NULL;
head->next=NULL;
return head;
}
int main()
{
STULST* head;
head=CreateList();
/// how to free the memory of head;
return 0;
}
Please help me to figure out this problem. In the following code
segment, how to free the momory allocated to "head" in {STULST*
CreateList()} in main() function? thanks
///////////////////////////////////////////
#include <stdio.h>
typedef struct
{
int num;
float score;
}STUDENT;
typedef struct STULST
{
STUDENT *stu;
struct STULST* next;
}STULST;
STULST* CreateList()
{
STULST *head;
head=(STULST *)malloc(sizeof(STULST));
head->stu=NULL;
head->next=NULL;
return head;
}
int main()
{
STULST* head;
head=CreateList();
/// how to free the memory of head;
return 0;
}