C go to start of linked list in loop -
hi have linked list defined
struct process { int a; struct process *next; }; typedef struct process node;
i have 2 nodes, 4 , 5 lets say.
i want loop goes through linked list , decrements each node 1 until 0.
any suggestions?
code have:
{ if (arrivaltime->next == null) { // printf("a is: %d \n", arrivaltime->a); printf("-- "); break; } else { // printf("a is: %d \n", arrivaltime->a); printf("-- "); arrivaltime->a--; arrivaltime = arrivaltime->next; } //arrivaltime = start; } while(1);
i can loop run once.
arrivaltime = start; while(arrivaltime == null) { arrivaltime->a--; printf("a is: %d \n", arrivaltime->a); arrivaltime = arrivaltime->next; }
Comments
Post a Comment