Well you probably shouldn't be modifying first, just to print it.
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
You have three cs there:
line 51
line 55
line 59
Your loop will never terminate because every c is always == first (so no matter which of the three the compiler chooses to use you've got an infinite loop).
Make sure to use just one c.
Also, watch how many times you change first. You want to bump it just once (if I understand you right).
void print() {
listitem *c=first;
if (c) {
printf("%d\n", *c);
c=first=first->next;
do{
printf("%d\n", *c);
c=c->next;
}while (c != first);
}
}
Hope this helps.
[edit] BTW. What if your circular list has just one item? (It will get printed twice.)
Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229
Use magical word virtual in
class rotatableList {
...
virtual void rotate () ...
...
};
and try again...
ArkM
Postaholic
2,001 posts since Jul 2008
Reputation Points: 1,234
Solved Threads: 348