i'll be very thankful if u can help me out here ...i have to write a program in c language ...to REVERSE A LINKED LIST.i have tried it until the point where the reversal is not used coz i don't know the logic which will be used to reverse a linked list....for example if a list is there like: 0->1->2->3->4->5->6
then the reverse of linked list would be 6->5->4->3->2->1->0.
i have tried it partially though...plz help me out and i'll be very greatful to u if u can help me in the reversing code....i've done something like this...
Code:
#include<stdio.h>
#include<conio.h>
struct link
{
int data;
struct link*ptr;
};
typedef struct link node;
int main()
{
int i,size;
node*start,*temp,*p,*last;
clrscr();
printf("enter the size of list");
scanf("%d",&size);
start=NULL;
for(i=0;i<size;i++)
{
 if(start==NULL)
   {
       start=(node*)malloc(sizeof(node));
       printf("enter the elements of list\n");
       scanf("%d",&start->data);
       start->ptr=NULL;
   }
  else
    {
  for(p=start;p->ptr!=NULL;p=p->ptr)
  temp=(node*)malloc(sizeof(node));
  scanf("%d",&temp->data);
  p->ptr=temp;
  temp->ptr=NULL;
    }
}
//now what do i do?after this?here the reverse of a linked list is to be done.....plz help me here..