We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
struct NODE{ struct NODE Succ; struct NODE Prev; }; struct LIST{ struct NODE *Head; struct NODE *Tail; int count; }; struct LIST *List; struct NODE *N; ...... for(N = List->Head;N;N = N->Succ) { ...... }
Your report is crucially incomplete. How do you detect that something happened to List->Head? There's not even a vague hint of actual results of running this code in your posting. And what side effect of
N=N->Succ
struct NODE{ struct NODE Succ; // should be *Succ struct NODE Prev; // should be *Prev };
You are right,I forgot asterisk.the orignal source code is as follow:
struct NODE{ struct NODE *Succ; struct NODE *Prev; };
N = N->Succ;
List->Head = List->Head->Succ;
N = List->Head;
the side effect of N = N->Succ; is that the compiler think about the statement as follow: List->Head = List->Head->Succ; What on earth made you believe that? N is a copy of List->Head, not an alias, so further modifications to N will not modify List->Head at all. You seem to be in serious need of a re-visit to your C textbooks to understand what pointers are, and how they work.