EmbLogic's Blog

LINKED LIST

#include<stdio.h>
#include<stdlib.h>

struct node
{
int data;
struct node *next;
};
typedef struct node item;
void main()
{
item *head[10];

int i;
for(i=0;i<10;i++)
{
head[i]=malloc(sizeof(struct node));
head[i]->data=i+5;
head[i]->next=head[i+1];
}

head[10]=NULL;

for(i=0;i<10;i++)
{
printf(“Address of head[%d] is %p and value is %d\n”,i,&head[i],head[i]->data);
}
}
its executing but am confused can smone tell me ??

One Response to LINKED LIST

  1. hemant.kumar says:

    if i comment the statement head[i]->next=head[i+1],
    its still executing with the same output

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>