hi all
i really hate this damn thing
Code:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct info
{
        int x;
        struct info *next;
};

int main()
{
        struct info *root;
        struct info *new;
        int v=0;
        root=malloc(sizeof(struct info));
        new->next=malloc(sizeof(struct info));
        new=new->next;
        while(new!=0)
        {
                new->x=5;
                new->next=malloc(sizeof(struct info));
                new=new->next;
                v++;
                if(v==5)
                {
                        new->next=0;
                        new=new->next;
                }
        }

        new=root;
        while(new!=0)
        {
                printf("%d\n",new->x);
                new=new->next;
        }
return 0;
}
it keep telling me
Segmentation fault
it should initialize x to 5 for 5 times

my question is
why it's not working ?