#include
#include "list.h"
#include
typedef struct list
{
int data;
struct list_head list;
} USER,*User;
struct list_head *Creat();
struct list_head Show(struct list_head *t);
main()
{
struct list_head *pt = NULL;
pt = Creat();
Show(pt);
}
struct list_head *Creat()
{
LIST_HEAD(t);
User H = NULL;
int ch = 1;
while(0 != ch)
{
printf("input a integer number(0 to stop):");
scanf("%d",&ch);
if(0 == ch)
{
break;
}
H = (User)malloc(sizeof(USER));
H->data = ch;
list_add_tail(&(H->list),&t);
}
return &t;
}
struct list_head Show(struct list_head *t)
{
User p = NULL;
struct list_head *pno = NULL;
list_for_each(pno,t)
{
p = list_entry(pno,USER,list);
printf("%d\n",p->data);
}
}
与我无关 于 2012-03-12 21:40:59发表:
加static