Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Pointer (computer programming)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
====C linked list==== Below is an example definition of a [[linked list]] in C. <syntaxhighlight lang="C"> /* the empty linked list is represented by NULL * or some other sentinel value */ #define EMPTY_LIST NULL struct link { void *data; /* data of this link */ struct link *next; /* next link; EMPTY_LIST if there is none */ }; </syntaxhighlight> This pointer-recursive definition is essentially the same as the reference-recursive definition from the language [[Haskell]]: <syntaxhighlight lang="haskell"> data Link a = Nil | Cons a (Link a) </syntaxhighlight> <code>Nil</code> is the empty list, and <code>Cons a (Link a)</code> is a [[cons]] cell of type <code>a</code> with another link also of type <code>a</code>. The definition with references, however, is type-checked and does not use potentially confusing signal values. For this reason, data structures in C are usually dealt with via [[wrapper function]]s, which are carefully checked for correctness.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)