How to use the C Pointer Visualizer
- 1. Write or load codeUse one of the six examples or type your own int and char statements with pointers and arrays.
- 2. Trace memoryThe tool runs each statement and records the memory after it.
- 3. Step throughChanged cells are highlighted, pointers show their target, and the printf output appears below.
Worked example: pointers and arrays
The "Pointers and arrays" example declares int a[4] = {10, 20, 30, 40}; at 0x1000, 16 bytes in all. int *p = a; holds 0x1000, the address of a[0]. After p++, p holds 0x1004, because adding 1 to an int pointer moves it by sizeof(int), 4 bytes. *p = 99; changes a[1]. p = p + 2; moves to a[3], so last becomes 40, and p - a is 3 elements, not 12 bytes. The printf prints 99 40 3, the same as the real program compiled with gcc.
Bugs it catches
- Dereferencing NULL ("a real program would most likely crash here").
- Using a variable before it has a value.
- A pointer that walks past the end of an array.
- Writing to a string literal, such as
char *s = "hi"; *s = 'H';. - Storing a plain number in a pointer, or an address in an int.
What's supported
This is a small teaching interpreter for part of C, written without eval: int and char variables, pointers (including pointers to pointers), arrays with initialisers, string literals, =, +=, -=, ++ and --, arithmetic, & and *, indexing, and printf with %d, %c, %s and %p. Loops, functions, structs and malloc aren't supported; write steps out one by one. Addresses are made up but follow real sizes: int 4 bytes, char 1, pointers 8.
Frequently asked questions
Are the addresses real?
No. They're invented so they're easy to read, but sizes and pointer arithmetic follow real 64-bit C rules.
Can I paste a full program?
Yes, if it uses only the supported parts. #include, int main() {, return 0; and } are skipped.
Does the code run on a server?
No. A small interpreter in your browser runs it.
Is the C pointer visualizer free?
Yes. Everything in the C pointer visualizer works without signing up. The first time you ask for a result, we ask once for your name and WhatsApp number; after that the C pointer visualizer and every other Uncodemy tool open straight away.