Does standard c library provides linked list etc. data structures? Does standard c library provides linked list etc. data structures? c c

Does standard c library provides linked list etc. data structures?


The C Standard does not provide data structures like linked list and stack.Some compiler implementations might provide their own versions but their usage will be non portable across different compilers.

So Yes, You have to write your own.


The C standard doesn't, glibc however provides lists, tail queues, and circular queues in <sys/queue.h> according to the queue man page those come from BSD and not POSIX.


There are hash tables, binary trees and binary search stuff in glibc.Those are part of C89, C99 and/or POSIX.1 standards.Some reason linked list is not there.

More info from man pages: hsearch, tsearch and bsearch

Note: Some of those have bad design. For example: hsearch allows only one hash table per process. The GNU compiler, gcc/glibc, provides reentrant versions hcreate_r, hsearch_r, and hdestroy_r that allow multiple hash tables. See also Stack Overflow's How to use hcreate_r.