[ create a new paste ] login | about

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

iamyeasin - C++, pasted on Feb 15:
#include<stdio.h>
#include<stdlib.h>

int main()
{
    struct node
    {
        int x;
        struct node *p;
    };

    typedef struct node pt;

    pt *o = (pt*) malloc(sizeof(pt));
    pt *head = o;

    for(int i=0; i<4; i++)
    {
        scanf("%d",&o->x);
        o->p = (pt*)malloc(sizeof(pt));

        o = o->p;
    }

    o->p = NULL;

    while(head -> p)
    {
        printf("%d \n",head->x);
        head = head->p;
    }


}


Output:
1
2
3
4
-1819044973 
-1819044973 
-1819044973 
-1819044973 


Create a new paste based on this one


Comments: