#include <stdio.h>
struct my_struct {
int a, b;
};
int
sort_cb(const void *d1, const void *d2)
{
const struct my_struct *x1, *x2;
l1 = d1;
l2 = d2;
return x1->a - x2->a;
}
int
main(void)
{
struct my_struct *d, *cur;
d = malloc(sizeof(*d));
d->a = 1;
d->b = 10;
d = malloc(sizeof(*d));
d->a = 2;
d->b = 20;
d = malloc(sizeof(*d));
d->a = 3;
d->b = 30;
printf("list=%p\n", list);
printf("\ta=%d, b=%d\n", cur->a, cur->b);
d = malloc(sizeof(*d));
d->a = 4;
d->b = 40;
printf("list after sort=%p\n", list);
printf("\ta=%d, b=%d\n", cur->a, cur->b);
if (tmp)
else
cur = NULL;
if (d != cur)
printf("wrong node! cur=%p\n", cur);
free(d);
printf("list=%p\n", list);
for (itr = list; itr != NULL; itr = itr->
next)
{
printf("\ta=%d, b=%d\n", cur->a, cur->b);
}
while (list)
{
struct my_struct);
free(aux);
}
return 0;
}