C/C++ code#include
#include
#include
#include
typedef struct Student{
int num;
int age;
struct Student *next;
}STU;
STU *creat(int n);
void printf_all(STU *pb);
void link_free(STU *head);
int main()
{
STU *head=NULL;
int n;
printf("input num you want creat node\n");
scanf("%d",&n);
head=creat(n); //创建n个结点
printf_all(head);
printf("we will free link\n");
link_free(head);
Sleep(100);
if(head==NULL) //困惑? head!=NULL?
{
printf("***********\n");
}
printf_all(head); //有错误,并有打印,为任意值
return 0;
}
STU *creat(int n)
{
STU *head,*pf,*pb;
int i;