C Tutorial

Introduction to C

Why C, the compilation process, and your first program

What is C?

C is a general-purpose, procedural programming language that was developed in the early 1970s at Bell Labs. It is often called the "Mother of all Languages" because it is the foundation for almost all modern systems and application software.
c
#include <stdio.h>

int main() {
    printf("Hello, Nocturnal Codex!\n");
    return 0;
}

Why Learn C today?

  1. Hardware Mastery: C gives you total control over memory and hardware. You learn exactly how the computer works under the hood.
  2. Unrivaled Speed: C code is compiled directly to native machine code. It is the language of choice for game engines, operating systems, and high-performance drivers.
  3. Portability: C code can be run on almost anything—from supercomputers to the tiny chip in your microwave.
  4. Legacy & Foundation: Understanding C makes it much easier to learn C++, Java, Rust, or Go.

The Compilation Process

Wait! Unlike interpreted languages (like Python), C code must be Compiled before it can run. This happens in four main steps:
  1. Preprocessing: Handling #include and #define directives.
  2. Compilation: Turning code into Assembly language.
  3. Assembly: Turning Assembly into machine code (Object files).
  4. Linking: Combining object files and libraries into a single Executable.
bash
gcc main.c -o my_program  # Compile using GCC
./my_program              # Run the executable

Key Characteristics

  • Statically Typed: Types are fixed at compile-time.
  • Manual Memory: You (the programmer) are responsible for allocating and freeing memory.
  • Low-Level: Provides direct access to memory via Pointers.
[!TIP] C is a small language. While it has very few "keywords," it provides infinite power. Mastery of C is the mark of a true software engineer.

Summary

FeatureDescription
CreatorDennis Ritchie (1972)
ParadigmProcedural, Structured
MemoryManual (No Garbage Collector)
SpeedBlazing fast (Native performance)
OutputBinary executable
Best ForOS Kernels, Embedded Systems, Game Engines
StandardANSI C, C99, C11, C17, C23
LogicClose to the metal; no hidden abstractions
SafetyMinimal safety; "With great power comes great responsibility"
IdentityThe foundation of the Unix operating system
WasmCan be compiled to WebAssembly for browser performance
PointerThe most powerful (and dangerous) feature of the language