Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- #include <stdlib.h>
- using namespace std;
- struct n {
- int x;
- n * next;
- };
- typedef n node;
- int main ()
- {
- node * root;
- root = (node *)malloc(sizeof(node));
- node * iter;
- iter = root;
- iter->x = 10;
- iter->next = (node *)malloc(sizeof(node));
- iter->next->x = 20;
- iter->next->next = (node *)malloc(sizeof(node));
- iter->next->next->x = 30;
- cout<<iter->x<<endl;
- iter = iter->next;
- cout<<iter->x<<endl;
- iter = iter->next;
- cout<<iter->x<<endl;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement