write a C code To reverse a linked list
Answers were Sorted based on User's Feedback
Answer / sujith
include <stdio.h>
typedef struct list {
list_t *next;
int data;
}list_t;
list_t *list_reverse(list_t *list)
{
list_t *rlist = NULL;
while (list != NULL)
{
list_t *next = list->next;
list->next = rlist;
rlist = list;
list = next;
}
return rlist;
}
This will do the job.
Plese do verify this.
Sujith
| Is This Answer Correct ? | 27 Yes | 12 No |
Differentiate between new and malloc(), delete and free() ?
What is the difference between array and structure in c?
How to delete a node from linked list w/o using collectons?
When is a void pointer used?
how do you execute a c program in unix.
why we use pointer in c
What is a lookup table in c?
what is array?
Is a house a shell structure?
What are local static variables?
What is structure of c program?
Do pointers take up memory?