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
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.
- Function Declaration & Definition — Prototypes, parameters, return types, and calling conventions
- Parameter Passing — Pass by value vs. pass by pointer (simulated pass by reference)
- Recursion — Self-referencing functions, base cases, and stack behavior
- Inline Functions — Compiler hints for function inlining and performance
- Variadic Functions — Functions with variable arguments — stdarg.h, va_list, va_arg
- The main() Function — Entry point, argc/argv, return values, and environment
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.
- Memory Layout — Stack, heap, data segment, BSS, and text segment
- Dynamic Allocation — malloc, calloc, realloc, free — and when to use each
- Memory Leaks — Detection, prevention, and tools like Valgrind
- Dangling Pointers — Use-after-free, double-free, and defensive patterns
5File Handling
Reading, writing, and manipulating files.
- File Operations — fopen, fclose, fread, fwrite, and file modes
- Formatted File I/O — fprintf, fscanf, and text file processing
- Binary Files — Reading/writing structs, fseek, ftell, rewind
- Error Handling in Files — errno, perror, ferror, and feof
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