CMD Simulator

MemC – See How C Uses Memory

Type C code, click Run or Step, and watch where variables and pointers live in memory

Quick Start (3 steps)

  1. Pick an example below or write your own C code
  2. Click Run to execute all at once, or Step to go line by line
  3. Watch the memory diagram update: Stack (local vars), Heap (malloc), and pointers
Try an example:
Your C code (must have main())
Controls

No memory to show yet

Click Run or Step to execute your code. The diagram will show where variables live: Stack (local vars), Heap (malloc blocks), and pointers between them.

Output (printf)

No output yet. Use printf("text") or printf("x = %d", x) to print.

What you'll see

  • Stack — Local variables (e.g. int x = 5) live here. Each function gets its own frame.
  • Heap — Memory from malloc() or calloc(). You must call free() when done.
  • Pointers — Variables like int* p store addresses. The arrow (→) shows what they point to.

Learn Memory Concepts

Example Programs