
self contained pointers to structures
Here's one that confounded me. I wanted to link a number of records of the
same type. Each record would have the same structure and would contain a
pointer to the next record. I tried to implement it like this:
struct event {
int timing:
int count;
struct event *next;
Quote:
};
Of course, the compiler complains because the definition of the structure is
incomplete at that point. From a practical point of view this shouldn't matter since the space into which the record will go be allocated memory. Does this
mean that I can define the pointer 'next' as char * and then do some coercion
in my code. I won't be using these structures in an array so all I feel
I really need is some pointer into memory.
Or should I define a similar structure and reference a pointer to it? This
does present the problem of what the struct * would have to be in that
definition.
I suspect that this subject has been discussed before but it didn't have my
attention at the time.
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
= I know it's petty.......... =
- But I have to justify my salary! -
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=