Anonymous user
Doubly-linked list/Element definition: Difference between revisions
Doubly-linked list/Element definition (view source)
Revision as of 09:41, 29 September 2020
, 3 years ago→{{header|C}}
(Added Algol W) |
|||
Line 131:
=={{header|C}}==
It basically doesn't matter if we use the name link, node, Node or some other name. These are matters of taste and aesthetics. However, it is important that the C language is case-sensitive and that the namespace for structures is separate.
<lang c>struct
{
struct
struct
void *data;
};</lang>
An alternative technique is to define a pointer type by typedef as shown below. The advantage here is that you do not have to write struct everywhere - assuming that you will most often need a pointer to a struct Node, not the structure itself.
<lang c>
struct Node;
typedef struct Node* Node;
struct Node
{
Node next;
Node prev;
void* data;
};
</lang>
=={{header|C sharp|C#}}==
|