Thursday 9 January 2014

HOW TO CREATE NODE IN C FOR LINKED LIST

#include<stdio.h>
struct node
{
 int info;
 struct node *next;

};
typedef struct node *newnode;
newnode first,newn,pred,temp,avail,save;
void main()
{
 int i,n,w,q,y,x;
 clrscr();
 textcolor(11);
 first=NULL;
 avail=(newnode)malloc(sizeof(struct node));
 avail->next=NULL;
 printf("\n\n\t\tENTER VALUE OF NODE WHICH YOU WANT TO CREATE NODE SPACE>>");
 scanf("%d",&n);
 temp=avail;
 for(i=1;i<n;i++)
 {

 temp->next=(newnode)malloc(sizeof(struct node));
 temp=temp->next;
 temp->next=NULL;

 }
getch();
}

No comments:

Post a Comment

How to change Background color by selecting color from Listview

activitymain.xml file::> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"     xm...