Data Structures in C
Arrays, strings, structures, unions, enums and typedefs — how C groups data. Structures/unions and bit fields also have their own pages.
This is an overview — pick a sub-topic below.
Sub-topics (10)
Arrays in C
Fixed-size sequences of elements of one type, stored contiguously.
Multidimensional Arrays
Arrays of arrays, stored row by row (row-major).
Strings in C
Arrays of `char` ending with a null byte `'\0'`.
String Library (string.h)
`strlen`, `strcpy`, `strncpy`, `strcat`, `strcmp`, `strchr`, `strstr`, `memcpy`, `memset`, `memcmp`.
Structures
Group related fields into one type.
Unions
Fields that share the same memory — only one is valid at a time.
Enumerations
Named integer constants.
typedef
Gives an existing type a new name.
Self-Referential Structures
A struct containing a pointer to its own type — the basis of linked lists and trees.
Flexible Array Members
A struct whose last member is an array of unknown size, allocated together with the struct.
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.