write a C code To reverse a linked list

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does the message "automatic aggregate intialization is an ansi feature" mean?

694


What does c mean in standard form?

596


C language questions for civil engineering

1239


How do shell structures work?

567


What is the purpose of void in c?

619






define string ?

666


What is pass by reference in functions?

323


Write a program with dynamically allocation of variable.

602


I have a varargs function which accepts a float parameter?

579


Do you have any idea how to compare array with pointer in c?

599


What is indirection?

650


When should the register modifier be used? Does it really help?

612


Differentiate between functions getch() and getche().

620


What is a program flowchart and how does it help in writing a program?

660


Why should I prototype a function?

636