C standard library is one library that's always linked by default when you compile C programs.
To use the library, a set of headers is offered which you can include by default.
For example, <stdlib.h> and <stdio.h> in this code are headers from the C standard library (but there are also headers which are not part of C standard library!).
<stdlib.h> provides a definition of the constant EXIT_SUCCESS<stdio.h> provides a declaration to the function printf()// Compile: gcc main.c -o program // Run: ./program #include <stdlib.h> #include <stdio.h> int main() { printf("Hello world!"); return EXIT_SUCCESS; }
Headers commonly define various constants (#define) e.g. <stdlib.h> defines EXIT_SUCCESS
$ grep -e EXIT_SUCCESS < /usr/include/stdlib.h #define EXIT_SUCCESS 0 /* Successful exit status. */
They also commonly declare various function calls e.g. <stdio.h> declares printf()
$ grep -e 'extern int printf' < /usr/include/ extern int printf (const char *__restrict __format, ...);
And they also declare various structs, unions, and typedefs
All headers all live in /usr/include directory and have the file extension “.h” – which stands for “header”. For example
/usr/include/stdio.h
The library itself lives in /usr/lib. It actually comes in two flavors:
/usr/lib/libc.a - Static library (.a stands for “archive”)/usr/lib/libc.so - Dynamic library (.so stands for “shared object”)Compared to standard libraries of modern programming languages – such as Rust, C++17, Python, JavaScript etc. – you'll find the C standard library frustratingly barren and austere.
It contains almost nothing!
Furthermore, many parts of the standard library are either dangerous (gets()), confusing (strtok()), near-duplicates (getc() and fgetc()), or not actually part of thes standard at all (itoa()).
No maps. No vectors. No lists or trees. Nothing.
If you want something like C++'s std::vector in C – i.e. a dynamically grown array – you'll have to go ahead make a struct for it and implement it yourself, with calloc(), realloc() and free()!
typedef struct _vector_t {
void* v_data;
size_t v_capacity;
size_t v_size;
} vector_t;
But many data structures common in higher programming languages – like C++'s std::map or Python's dict {a: 1, b: 2} – are internally implemented through non-trivial data structures like B-trees or Red-black trees.
While C might be conceptually the fastest programming language in existence (you're a hair away from writing machine code!) if you don't bother to implement fast data structures you won't see that.
No JSON. No YAML. No XML. No ini files. Nothing.
No directory traversal. No file permission.
No sockets. No web servers. No requests. Nothing.
No emojis. No CJK, arabic.