pointers within a structure 
Author Message
 pointers within a structure

What would the purpose be for including the 'next' and 'prior' pointers
in a structure like this:

struct media_spec {
  char spec_number[20];
  char revision;
  int  eng_notice;
  char active;
  struct media_spec *next, *prior;

Quote:
};

It's from an old DOS program that uses a binary file of these structures
as a sort of database. I assume the pointers are required for some C
library search function?

drc



Mon, 21 Apr 2003 23:50:28 GMT  
 pointers within a structure
A linked list.

Matt


Quote:
> What would the purpose be for including the 'next' and 'prior' pointers
> in a structure like this:

> struct media_spec {
>   char spec_number[20];
>   char revision;
>   int  eng_notice;
>   char active;
>   struct media_spec *next, *prior;
> };

> It's from an old DOS program that uses a binary file of these structures
> as a sort of database. I assume the pointers are required for some C
> library search function?

> drc



Tue, 22 Apr 2003 00:01:20 GMT  
 pointers within a structure
Such pointers strongly suggest the structure was intended to be used as a
node in a double-linked list.
--
With best wishes,
    Igor Tandetnik


Quote:
> What would the purpose be for including the 'next' and 'prior' pointers
> in a structure like this:

> struct media_spec {
>   char spec_number[20];
>   char revision;
>   int  eng_notice;
>   char active;
>   struct media_spec *next, *prior;
> };

> It's from an old DOS program that uses a binary file of these structures
> as a sort of database. I assume the pointers are required for some C
> library search function?

> drc



Tue, 22 Apr 2003 00:02:46 GMT  
 pointers within a structure
Its probably a double linked list.
If you dont know what that is then in few words...
You keep a pointer to one record.. each record point to the one before it
and the one after it.. you can now add a new structure and simply append it
or insert it or whatever you fancy.. this way your list can grow from
nothing to all avail memory


Quote:
> What would the purpose be for including the 'next' and 'prior' pointers
> in a structure like this:

> struct media_spec {
>   char spec_number[20];
>   char revision;
>   int  eng_notice;
>   char active;
>   struct media_spec *next, *prior;
> };

> It's from an old DOS program that uses a binary file of these structures
> as a sort of database. I assume the pointers are required for some C
> library search function?

> drc



Tue, 22 Apr 2003 00:15:31 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. pointers within an array of structures

2. Help in initializing function pointers within structures

3. Accessing fields within structures with pointers...

4. help: accessing a pointer to a list within an array of structures

5. structures within structures

6. Q about structures within structures

7. Initialising Structure Within Structure...How?!

8. Pointers to Structure that contains pointer to Function

9. Assigning structure pointer to function pointer

10. pointers,structures, and character pointers

11. pointers, structures, and character pointers

12. Help! with pointers to pointers to structures

 

 
Powered by phpBB® Forum Software