Skip to content

Chapter 1 of 21

Introduction to C

Discover C’s history, strengths, toolchain, and first program.

18 minutes 10 quick checksBy Subha Prasad
Lesson 1 of 21Course navigation

Lesson content

Read, practise, then check your understanding

C is a general-purpose, compiled programming language created by Dennis Ritchie at Bell Labs in the early 1970s. It grew alongside Unix: a small language could express operating-system code efficiently while remaining portable across machines. Modern C is standardized by ISO; important editions include C89/C90, C99, C11, C17, and C23. Compilers may support different editions, so production projects should state the standard they require.

Why C still matters

C exposes a compact abstraction over machine memory. It offers structured control flow, functions, arrays, structures, pointers, and a small standard library without automatic garbage collection or a large runtime. That makes it common in operating systems, embedded firmware, device drivers, databases, language runtimes, networking libraries, and performance-critical components.

Its strengths—predictable layout, direct memory access, portability, and mature tooling—also create responsibility. The programmer must respect object lifetimes, array bounds, types, and resource ownership. C is not “unsafe by default” so much as explicit by default.

From source to executable

A typical build passes through four conceptual stages:

  1. The preprocessor expands directives such as #include and macros.
  2. The compiler parses and translates C into assembly or object code.
  3. The assembler creates machine-code object files.
  4. The linker combines objects and libraries, resolving external names.

With GCC or Clang, one command usually drives all stages:

cc -std=c17 -Wall -Wextra -Wpedantic hello.c -o hello
./hello

On Windows, use a supported toolchain such as Visual Studio’s MSVC, LLVM/Clang, or GCC through MSYS2. An editor is not a compiler; configure both the editor and toolchain, then verify cc --version or the equivalent command.

Your first program

#include <stdio.h>

int main(void) {
    puts("Hello, C!");
    return 0;
}

stdio.h declares the standard input/output functions. main is the hosted program entry point. puts writes a line, and returning 0 reports success to the environment.

Build for feedback

Warnings are part of the development workflow, not cosmetic noise. A practical debug build is:

cc -std=c17 -Wall -Wextra -Wpedantic -Wconversion -g main.c -o app

During testing, Clang and GCC sanitizers can expose invalid memory use and undefined behavior:

cc -std=c17 -g -fsanitize=address,undefined main.c -o app

Compile often, read the first diagnostic first, and keep programs small while learning. Every later chapter builds on this toolchain.

Knowledge check

Answer every question correctly to complete this chapter.

Who created the C programming language?
What does a C compiler primarily produce from source code?
C was developed closely alongside which operating system?
Which build stage expands #include directives and macros?
What is the linker responsible for?
Which compiler option selects the C17 language edition with GCC or Clang?
Why are compiler warnings important?
Which header declares puts?
What does returning 0 from main conventionally report?
What is AddressSanitizer primarily used to detect?

0 of 10 checks passed

Your progress is saved on this device.