This is my list declaration
Code:
#define Nil NULL
#define info(P) (P)->info
#define next(P) (P)->next
#define First(L)((L).First)
typedef int infotype;
typedef struct tElmtlist *address;
typedef struct tElmtlist
{
infotype info;
address next;
}Elmtlist;
typedef struct
{
address First;
}List;
i have this procedure:
void DeleteLast(List * L,infotype * X)
/*is : list not empty
fs : last Element list deleted. X save its value*/
{
address Last,Prev;
Last = First(*L);
Prev = Nil;
First(*L)=Last;
while (next(Last) != Nil)
{ Prev = Last;
Last = next(Last);
}
*X = info(Last);
next(Prev) = Nil;
}
why if i changed the procedure become:
void DeleteLast(List * L,infotype * X)
{
address Last;
Last = First(*L);
First(*L)=Last;
while (next(Last) != Nil)
{ Last = next(Last);
}
*X = info(Last);
Last = Nil;
} the procedure not work when i print all list element i still have last element