fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct LinkedList
  5. {
  6. int x;
  7. LinkedList() : x(99) {}
  8. LinkedList* next;
  9. };
  10.  
  11. int main() {
  12. LinkedList *r, *s, **rP = &r;
  13.  
  14. int i = 0;
  15. while(i < 10)
  16. {
  17. s = new LinkedList;
  18. *rP = s;
  19. rP = &s->next;
  20. ++i;
  21. }
  22.  
  23. *rP = NULL;
  24. std::cout << r->x << std::endl;
  25. }
  26.  
Success #stdin #stdout 0s 5304KB
stdin
Standard input is empty
stdout
99