Thursday, July 9, 2009

How can i manipulate a double pointer in c programming?

i will use it in creating a program like a phonebook... i have to have a pointer that will point in the previous and next entry.

How can i manipulate a double pointer in c programming?
There's no such things as double pointers in C, you need two separate pointers. What you're describing is a doubly linked list, where each entry in the list has two pointers, one pointing to the next list entry and one pointing to the previous list entry.





Each entry could be defined as something like the following:





struct bookentry {





/* Define data fields for an entry here (eg name, phone number etc) */





/* Pointers to next and previous entries */


struct bookentry *next;


struct bookentry *previous;


};





See the following link for a simple example of how you could create and manipulate a doubly linked list:





http://www.c.happycodings.com/Data_Struc...
Reply:I think you need two separate single pointers for that.
Reply:Search and read about doubly linked list. Actually you will have two pointers in the structure. One pointer to point to next node and other to point previous node.


No comments:

Post a Comment