1: typedef struct list_
2: {
3: struct list_ *next;
4: int data;
5: }list_t;
6: void delete_list(int pos,list_t *node)
7: {
8: if ( NULL == node)
9: {
10: printf("Position not found\n");
11: return;
12: }
13: if ( pos == 1)
14: {
15: while ( node->next->next != NULL )
16: {
17: node->data = node->next->data;
18: node=node->next;
19: }
20: node->data = node->next->data;
21: free(node->next);
22: node->next = NULL;
23: return;
24: }
25: delete_list(--pos,node->next);
26: return;
27: }
28: main()
29: {
30: delete_list(pos,start);
31: }
RTOS, Linux Kernel internal, OS-Programming C & Data Structures, Debugging, Optimizations, Makefiles and Wireless Technologies (Wi-Fi ,LTE and LTE-Advanced )
Search This Blog
Sunday, September 21, 2014
WAP to delete node in singly linked list when position and start pointer is given. Without using extra pointer
Labels:
C,
Data Structure
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment