Course

C from the ground up

The small language under everything else

  • Beginner
  • 12 chapters
  • 180 min read

Learn C by running it: main and printf, whole and decimal numbers, decisions, loops, functions and prototypes, arrays and sizeof, strings as char arrays, pointers and a swap through addresses, structs with typedef, malloc and free, the preprocessor, and a capstone that uses them all at once.

What You'll Learn

  • Write and run a C program, and read what the compiler reports
  • Store whole numbers and decimals, and know why integer division truncates
  • Choose a path with if, else if and else, and compare values correctly
  • Repeat work with for, while and do loops, and stop them on time
  • Name work as functions, and promise the compiler a prototype
  • Keep values in arrays, count them with sizeof, and walk them with a loop
  • Treat text as char arrays and use strlen, strcmp and strcpy
  • Hold addresses in pointers, follow them, and swap values through them
  • Group fields into a struct and shorten the type with typedef
  • Ask for memory at run time with malloc, use it like an array, and free it
  • Name constants and small rules with the preprocessor and define
  • Build a capstone: a struct, a dynamic list, functions and a report

Prerequisites

  • No C at all — the course starts at the first include line
  • Any experience with one other language makes the early chapters quicker, but none is assumed

Course Content

  1. 01
    Your first C program

    What C is, the shape every program shares, and your first run: two lines printed with printf and a value threaded into the text.

    Beginner · 12 min read

    Not started
  2. 02
    Whole numbers and decimals

    The two kinds of number C cares about, why dividing two whole numbers throws the fraction away, and how to print each kind cleanly.

    Beginner · 14 min read

    Not started
  3. 03
    Decisions with if and else

    Make a program choose a path: the if statement, the comparison operators, and the difference between one equals sign and two.

    Beginner · 12 min read

    Not started
  4. 04
    Repeating work with loops

    C has three loops and a reason to pick each one: for when you count, while when you wait, and do while when the body must run once.

    Beginner · 14 min read

    Not started
  5. 05
    Functions and prototypes

    Name a piece of work and reuse it: how a function returns a value, why C wants to know about it in advance, and the prototype that says so.

    Intermediate · 14 min read

    Not started
  6. 06
    Arrays and sizeof

    Store many values of one type in a row, start counting at zero, walk the array with a loop, and let sizeof tell you how many there are.

    Intermediate · 15 min read

    Not started
  7. 07
    Strings as char arrays

    C has no string type: text is a char array ending in a zero. Meet strlen, strcmp and strcpy, the functions that know where the text ends.

    Intermediate · 16 min read

    Not started
  8. 08
    Pointers and addresses

    Every value lives at an address. A pointer holds one, the star follows it to the value, and that is how a function changes the caller's variable.

    Intermediate · 17 min read

    Not started
  9. 09
    Grouping values with struct

    When values belong together, wrap them in a struct. Define a new type, name its fields, and give it a short alias with typedef.

    Advanced · 15 min read

    Not started
  10. 10
    Memory you ask for

    Fixed arrays have a fixed size. malloc asks the system for memory while the program runs, and free hands it back when you are done.

    Advanced · 18 min read

    Not started
  11. 11
    The preprocessor and define

    Before C sees your file, the preprocessor edits it: pulling in headers and replacing names. define gives a value or a tiny rule a name.

    Advanced · 13 min read

    Not started
  12. 12
    Putting it together: a roster

    A capstone that uses the whole course at once: a struct type, memory asked for at run time, a function that reads it, and a final report.

    Advanced · 20 min read

    Not started