1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| typedef struct _Dliste {
struct _Dliste *next;
struct _Dliste *prev;
void * info;
}Dliste;
Dliste* get_first(Dliste* ref)
{
if(ref==NULL)
return NULL;
while(ref->prev!=NULL)
ref=ref->prev;
ref->next=ref;
return ref;
}
main()
{
int a,b,c,d;
Dliste* trouve;
Dliste*ref=NULL;
a=1;
b=2;
c=3;
d=4;
ref=node_create(a);
printf("%d\n",ref->info);
add_tail(ref, b);
add_tail(ref, c);
add_tail(ref, d);
printf("b=%d\n",ref->info);
if(ref==NULL)
printf("faux");
while(ref!=NULL)
{
printf("%d\n",ref->info);
ref=ref->next;
}
trouve = get_first(ref);
printf("trouve= %d\n",((int)trouve->info));
system("PAUSE");
} |
Partager