Reading input with scanf
scanf waits for two numbers; type them in the output panel.
#include <stdio.h>
int main(void) {
int a, b;
scanf("%d %d", &a, &b);
printf("%d + %d = %d\n", a, b, a + b);
return 0;
}Free, no gcc to install, no sign-in. Run it, then watch every pointer and malloc’d block, step by step.
Each variable sits in its function’s frame on the stack; malloc’d blocks sit on the heap; a pointer is an arrow. A freed block turns grey, a lost one red.
As handy as VS Code on your computer, plus what it does not have: every step drawn.
Press Step and the code stops at each line: the lit line runs next, and every variable’s value sits beside it. Go back too, with the ← → keys.

Under the error, press “See how it went wrong”: the visualizer opens at the failing step, in red, with the reason in plain words. Step back through everything before it.

A link opens this very code. Or export a GIF of it running (light or dark, wide or tall) or a picture of the code, and post it to X, a chat, or embed it in a blog.

Each one can be stepped through and visualized. Change it, run it again.
scanf waits for two numbers; type them in the output panel.
#include <stdio.h>
int main(void) {
int a, b;
scanf("%d %d", &a, &b);
printf("%d + %d = %d\n", a, b, a + b);
return 0;
}The classic: why swap needs &x and &y.
#include <stdio.h>
void swap(int *a, int *b) {
int t = *a;
*a = *b;
*b = t;
}
int main(void) {
int x = 3, y = 5;
swap(&x, &y);
printf("%d %d\n", x, y);
return 0;
}a[i] and *(p + i) are the same element.
#include <stdio.h>
int main(void) {
int a[4] = {10, 20, 30, 40};
int *p = a;
for (int i = 0; i < 4; i++)
printf("%d %d\n", a[i], *(p + i));
return 0;
}A char array, strlen, two ends swapping inwards.
#include <stdio.h>
#include <string.h>
int main(void) {
char s[20] = "hello";
int n = strlen(s);
for (int i = 0; i < n / 2; i++) {
char t = s[i];
s[i] = s[n - 1 - i];
s[n - 1 - i] = t;
}
printf("%s\n", s);
return 0;
}Ask for n ints on the heap, use them, free them.
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int n = 5;
int *sq = malloc(n * sizeof(int));
for (int i = 0; i < n; i++)
sq[i] = i * i;
for (int i = 0; i < n; i++)
printf("%d ", sq[i]);
printf("\n");
free(sq);
return 0;
}Find the best score among students.
#include <stdio.h>
struct Stu {
char name[10];
int score;
};
int main(void) {
struct Stu s[3] = {{"Lin", 88}, {"Zhou", 95}, {"Chen", 79}};
int best = 0;
for (int i = 1; i < 3; i++)
if (s[i].score > s[best].score) best = i;
printf("%s %d\n", s[best].name, s[best].score);
return 0;
}Nodes from malloc, linked by pointers, then freed.
#include <stdio.h>
#include <stdlib.h>
struct Node {
int val;
struct Node *next;
};
int main(void) {
struct Node *head = NULL;
for (int i = 3; i >= 1; i--) {
struct Node *p = malloc(sizeof(struct Node));
p->val = i;
p->next = head;
head = p;
}
for (struct Node *p = head; p != NULL; p = p->next)
printf("%d ", p->val);
printf("\n");
while (head) {
struct Node *nx = head->next;
free(head);
head = nx;
}
return 0;
}A multiplication table, drawn as a grid in the visualizer.
#include <stdio.h>
int main(void) {
int t[3][4];
for (int i = 0; i < 3; i++)
for (int j = 0; j < 4; j++)
t[i][j] = (i + 1) * (j + 1);
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 4; j++)
printf("%3d", t[i][j]);
printf("\n");
}
return 0;
}A function that calls itself: watch the frames stack up.
#include <stdio.h>
int fib(int n) {
if (n <= 2) return 1;
return fib(n - 1) + fib(n - 2);
}
int main(void) {
printf("%d\n", fib(6));
return 0;
}Neighbours swap until the array is in order.
#include <stdio.h>
int main(void) {
int a[6] = {5, 2, 9, 1, 7, 3};
int n = 6;
for (int i = 0; i < n - 1; i++)
for (int j = 0; j < n - 1 - i; j++)
if (a[j] > a[j + 1]) {
int t = a[j];
a[j] = a[j + 1];
a[j + 1] = t;
}
for (int i = 0; i < n; i++) printf("%d ", a[i]);
printf("\n");
return 0;
}A loop, % and if / else if.
#include <stdio.h>
int main(void) {
for (int i = 1; i <= 15; i++) {
if (i % 15 == 0) printf("FizzBuzz\n");
else if (i % 3 == 0) printf("Fizz\n");
else if (i % 5 == 0) printf("Buzz\n");
else printf("%d\n", i);
}
return 0;
}Real gcc runs on quietly; here it stops at the bad read and shows why.
#include <stdio.h>
int main(void) {
int a[5] = {1, 2, 3, 4, 5};
int sum = 0;
for (int i = 0; i <= 5; i++)
sum += a[i];
printf("%d\n", sum);
return 0;
}No and no. Open the page and write C; your code stays in your own browser.
It is our own C engine running in your browser, made to give the same output as gcc 13 for C11 programs. Unlike gcc it stops at undefined behaviour, such as reading past an array, and tells you where.
When it reaches scanf, a box appears in the output: type, press Enter, it carries on.
Press Visualize: the stack is on the left, the heap on the right, and every pointer is an arrow. Freed blocks turn grey; leaked ones are red at the end.
Under the error, press “See how it went wrong”: the visualizer opens at the failing step and you can go back through it.
Yes. Tap the code to write full screen, with keys for Tab, braces and semicolons.
In this browser, under My code. Share anything important as a link.
Share → Copy link, or export a GIF of it running, or a picture of the code, and post it to X.