English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

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.

2007-03-13 22:53:08 · 3 answers · asked by enay_21 1 in Computers & Internet Programming & Design

3 answers

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_Structures/code3.html

2007-03-14 00:17:15 · answer #1 · answered by Groucho Returns 5 · 0 0

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.

2007-03-13 23:18:01 · answer #2 · answered by Atif Majid 3 · 0 0

I think you need two separate single pointers for that.

2007-03-13 23:08:47 · answer #3 · answered by icnintel 4 · 0 0

fedest.com, questions and answers