fork(1) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct NODE
  6. {
  7. int data;
  8. NODE *next;
  9. };
  10.  
  11. int main()
  12. {
  13. int i,j=0;
  14. NODE *start=NULL,*ptr,*temp;
  15. for (i=1; i<=10; i++)
  16. {
  17. ptr = new NODE;
  18. ptr->data=i;
  19. ptr->next=start;
  20. start=ptr;
  21. }
  22. for ( temp = start; temp; temp = temp->next )
  23. cout << temp->data << ' ';
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
10 9 8 7 6 5 4 3 2 1