coderef

C Quick Reference

C essentials: types, printf/scanf, arrays, strings, pointers, structs, memory, files and compiling.

6 sections · 33 snippets · updated Oct 14, 2026

Click any snippet to copy it.

Basics

Program structure and types.

  • Hello world
  • Variables
  • Constant
  • Booleans
  • Print formatted
  • Read input
  • Size of a type

Control flow

Conditions and loops.

  • If / else
  • Switch
  • For / while
  • Do-while

Arrays & strings

Fixed-size data and text.

  • Array
  • String
  • String length / copy
  • Compare strings
  • Concatenate
  • Format into a string
  • Number from string

Pointers & memory

Addresses and the heap.

  • Pointer basics
  • Pass by pointer
  • Allocate memory
  • Zeroed / resized memory
  • Free memory

Structs & functions

Grouping data and code.

  • Struct
  • Typedef
  • Member access
  • Function
  • Prototype (declare before use)
  • Enum

Files & compiling

I/O and building.

  • Write a file
  • Read lines
  • Compile and run
  • Command-line arguments

← All quick references