Actually i am trying to learn data structures and came to linked list ,i tried to make a program and according to my knowledge its correct as the compiler(code::blocks) is showing 0 error 0 warnings, but still when i run my compiled program it crashes and stops execution don't kno why? pls help in the matter
THE CODE IS:
Code:
#include<stdio.h>
#include<strings.h>
#include<stdlib.h>
#include<malloc.h>
struct node
{
int data;
struct node *next;
};
typedef struct node link;
link create_link(link *r);
main()
{
link *trys,*k;
int i,j,p;
k=trys;
printf("Enter the Number data\n");
scanf("%d",trys->data);
trys->next=NULL;
p: ;
printf("\nDo you want to add more numbers?(Y=1/N=0)");
scanf("%d",&i);
if(i==1)
{
for(j=0;trys->next!=NULL;j++)
trys=trys->next;
create_link(trys);
{
trys=k;
for(j=0;trys->next!=NULL;j++)
trys=trys->next;
printf("\nEnter the next Number data\n");
scanf("%d",trys->data);
}
trys=k;
goto p;
}
else
{
printf("\nNumber dat entered by you is:\n");
for(j=0;trys->next!=NULL;j++)
{
printf("%d\n",trys->data);
}
}
}
link create_link(link *r)
{
link *addon;
addon=malloc(sizeof(link));
r->next=addon;
addon->next=NULL;
}