mic85rm
18-01-2011, 00:26
struct posizione {
int x;
int y;
struct posizione *pun;
};
struct posizione *testa=NULL;
int push(struct posizione *p)
{
struct posizione *newp;
newp=(struct posizione *)malloc(sizeof(struct posizione));
if (newp!=NULL)
{
newp->x=p->x;
newp->y=p->y;
newp->pun=testa;
testa=newp; //non mi è chiaro questo passaggio
return 0;
}
else
{
return 1;
}
}
è corretto secondo voi?
int x;
int y;
struct posizione *pun;
};
struct posizione *testa=NULL;
int push(struct posizione *p)
{
struct posizione *newp;
newp=(struct posizione *)malloc(sizeof(struct posizione));
if (newp!=NULL)
{
newp->x=p->x;
newp->y=p->y;
newp->pun=testa;
testa=newp; //non mi è chiaro questo passaggio
return 0;
}
else
{
return 1;
}
}
è corretto secondo voi?