我有以下代码:(由 Armin 提供)
int InsForward (TL2 p, void* x){
/* Inserta a node a step forward from the supplied p*/
TL2 h = (TL2)calloc(1,sizeof(TCel2));
if (!h)
return 0;
h->pre = p; //sets h previous to point to p
h->nxt= p->nxt; //sets h next to point to where p was pointing ( sentinel )
p->nxt->prv = h; //sets the sentinel previous to point to h
p->nxt = h; //sets the p next to point to h
h->info = x;
return 1;
我尝试了什么:
/* TCel a, int p, FILE fi*/
while(fscanf(fi,"%i%i", &(p.x), &(p.y)) == 2)
if ( InsForward(a, &p) == 0)
break;
结构:
typedef struct cel2
{
struct cel2 *pre, *nxt;
void* info;
} TCel2, *TL2;
所以我检查了它:
/* TL2 u*/
for (u = a->nxt; u != a; u = u->nxt)
printf("%p \n", u->info);
是的,信息是无效的,但我很好奇地址是否不同......我想不是:
0028FEA8 0028FEA8 0028FEA8 0028FEA8 0028FEA8 0028FEA8
为什么都一样?!