link list in c



//implementation of link list in c
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
typedef struct node
{
int data;
struct node *link;
}NODE;
NODE *ptr,*start,*prev;
int i;
clrscr();
start=NULL;
printf("\nEnter 10 elements in array\n");
for(i=0;i<10;i++)
{
ptr=(NODE *)malloc(sizeof(NODE *));
scanf("%d",&ptr->data);
ptr->link=NULL;
if(start==NULL)
{
start=ptr;
}
else
{
prev->link=ptr;
}
prev=ptr;
}
ptr=start;
printf("\nElements in array\n");
for(i=0;i<10;i++,ptr=ptr->link)
printf("\na[%d]=%d",i,ptr->data);
getch();
}

*****output******



No comments:

Post a Comment

using avrdude with AVR studio(for windows 10 only)

Requirements 1. arduino-1.6.5-r2-windows.exe 2. as6installer-6.0.1843.exe When I try to configure avrdude in avr studio 6 then wina...