Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Do standard C library implementations, especially glibc (the GNU C Library) provide linked lists, stack et al. data structures, or do we have to roll our own?

Thanks.

like image 657
rsjethani Avatar asked Dec 22 '12 09:12

rsjethani


People also ask

Does C have built in data structures?

The C Programming language has many data structures like an array, stack, queue, linked list, tree, etc. A programmer selects an appropriate data structure and uses it according to their convenience.

What is linked list in C in data structure?

What is Linked List in C? A Linked List is a linear data structure. Every linked list has two parts, the data section and the address section that holds the address of the next element in the list, which is called a node.

Can we use linked list in C?

A linked list is a sequence of data structures, which are connected together via links. Linked List is a sequence of links which contains items. Each link contains a connection to another link.

Is list a data structure in C?

Lists are one of the most popular and efficient data structures, with implementation in every programming language like C, C++, Python, Java, and C#.


Video Answer


2 Answers

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.

like image 57
Alok Save Avatar answered Oct 01 '22 11:10

Alok Save


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.

like image 30
iabdalkader Avatar answered Oct 01 '22 12:10

iabdalkader