[ create a new paste ] login | about

Link: http://codepad.org/Es9Q7RDy    [ raw code | output | fork ]

C++, pasted on Sep 21:
#include <stdio.h>

struct entry
{
    int val;
    struct entry *next;
}n1,n2,n3;


int main()
{
   n1.val=100;
   n1.next=&n2;
   n2.val=200;
   n2.next=&n3;
   n3.val=300;
   n3.next=0l;


 const entry* ptr = &n1;
 do
 {
     printf("%d\n",ptr->val);
 }
 while(  (ptr=ptr->next, ptr) !=0l );
 

   return 0;
}


Output:
1
2
3
100
200
300


Create a new paste based on this one


Comments: