Monday, 12 September 2016

pointer with error

struct list{
    int n;
     struct list *next;
};

typedef struct list node;

node *temp,*start,*n_node;

node* getnode();

void insrt_nod(node*);
void show();

node* getnode()
{
    int n;
    temp=(node*)malloc(sizeof(node));
    temp->next="NULL";
    printf("\n enter the data:");
    scanf("%d",&n);
    return (temp);
}
void insrt_nod(node* temp)
{
    if(start=="NULL")
        start->next=n_node;
    else
    {
        temp=start;
        while(temp->next!="NULL")
            temp=temp->next;
        temp->next=n_node;
    }
}
void show()
{

    temp=start;
while(temp->next!="NULL")
           {
            temp=temp->next;
            printf("\n%d",temp->n);}
}


void main()
{
    printf("\n enter:\n");

n_node=getnode();
insrt_nod(n_node);
show();
}

No comments:

Post a Comment