C

The foundational systems language that powers operating systems, embedded devices, and performance-critical software.

Procedural
Imperative
Advanced
1972
Dennis Ritchie

Overview

C is a general-purpose programming language that has had a profound influence on many other languages. It was originally developed at Bell Labs for the Unix operating system. C provides low-level access to memory, maps efficiently to machine instructions, and requires minimal runtime support, making it ideal for systems programming. Nearly every modern OS kernel is written primarily in C.

Key Features

  • Low-level memory access — Pointers and direct memory manipulation
  • Minimal runtime — No garbage collector, tiny standard library
  • Portable — Compilers exist for virtually every platform
  • Efficient — Maps closely to hardware instructions
  • Foundational — Influenced C++, Java, C#, Go, Rust, and many more

Common Use Cases

  • Operating Systems — Linux, Windows, macOS kernels
  • Embedded Systems — Microcontrollers, firmware, IoT
  • Compilers & Interpreters — GCC, CPython, Lua
  • Databases — SQLite, PostgreSQL, MySQL
  • Networking — Network stacks, protocol implementations

Code Example

c
#include <stdio.h>
#include <stdlib.h>

// Dynamic array with manual memory management
int main() {
    int n = 5;
    int *arr = (int *)malloc(n * sizeof(int));

    for (int i = 0; i < n; i++) {
        arr[i] = i * i;
        printf("%d ", arr[i]);
    }
    printf("\n");

    free(arr);
    return 0;
}

Learning Resources

Learning Path

38 topics across 7 sections

1Basics

Fundamentals of variables, data types, I/O, and control flow.

  • Introduction to C — History, features, and why C remains essential today
  • Compilation Process — Preprocessing, compiling, assembling, and linking — how source becomes executable
  • Variables & Data Types — int, float, char, double, type modifiers, and sizeof
  • Input/Output — printf, scanf, formatted I/O, and escape sequences
  • Operators — Arithmetic, relational, logical, bitwise, assignment, and ternary operators
  • Control Flow — if/else, switch, for, while, do-while, break, continue, goto

2Functions

Modular programming with reusable code blocks.

3Compound Data Types

Structured data beyond primitives.

  • Arrays — One-dimensional, multi-dimensional arrays, and array decay
  • Pointers — Address-of, dereference, pointer arithmetic, NULL, void pointers
  • Strings — Character arrays, string.h functions, null termination
  • Structures — struct definition, member access, nested structs, typedef
  • Unions — Shared memory, type-punning, and when to use unions
  • Enumerations — Named integer constants with enum
  • Function Pointers — Callbacks, dispatch tables, and polymorphism in C

4Memory Management

Manual memory control — the core of C's power and danger.

5File Handling

Reading, writing, and manipulating files.

6Preprocessor & Build System

Compile-time directives and multi-file projects.

  • Preprocessor Directives — #include, #define, #ifdef, #pragma, and conditional compilation
  • Macros — Object-like vs function-like macros, pitfalls, and best practices
  • Header Files — Include guards, forward declarations, and API design
  • Multi-file Projects — Separate compilation, linking, and Makefiles
  • Storage Classes — auto, static, extern, register — scope and lifetime

7Advanced Topics

Low-level and systems-level programming techniques.

  • Bit Manipulation — Bitwise operators, bit fields, flag patterns, and masks
  • System Calls — open, read, write, close — POSIX I/O at the kernel boundary
  • Signals — Signal handling with signal() and sigaction()
  • Socket Programming — TCP/UDP client-server communication with Berkeley sockets
  • Multithreading — POSIX threads (pthreads), mutexes, and condition variables
  • Undefined Behavior — Common UB pitfalls and how to write safe, portable C code