Site Tools


c-standard-library

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
c-standard-library [February 20, 2026 at 02:32] yanevskivc-standard-library [August 22, 2026 at 15:22] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +# C standard library
 +
 +**[C standard library](https://en.cppreference.com/w/c/header)** is the core set of headers and functions always linked into C programs, providing essential utilities like I/O (`<stdio.h>`), memory management (`<stdlib.h>`), string handling (`<string.h>`), and math operations (`<math.h>`). Headers declare functions and constants; the library implementation lives in `libc.so` (dynamic) or `libc.a` (static).
 +
 +Modern C lacks advanced data structures (no maps, vectors, or trees), async/threading, and networking—you must implement these yourself or use external libraries.
 +
 +## Example
 +
 +This example demonstrates basic C standard library usage with I/O and memory allocation.
 +
 +```c
 +// compile: gcc -o stdlib stdlib.c
 +// run: ./stdlib
 +// description: use standard library for I/O, memory, and string operations
 +
 +#include <stdio.h>
 +#include <stdlib.h>
 +#include <string.h>
 +
 +int main() {
 +    char *buffer = malloc(50);
 +    if (!buffer) {
 +        fprintf(stderr, "Memory allocation failed\n");
 +        return EXIT_FAILURE;
 +    }
 +    
 +    strcpy(buffer, "Hello from stdlib");
 +    printf("%s\n", buffer);
 +    
 +    free(buffer);
 +    return EXIT_SUCCESS;
 +}
 +```