Online C++ compiler
Visualize
See your code run, step by step
The fastest way to understand loops, recursion, lists and objects, and to find bugs.
- The line that just ran and the line that runs next, highlighted in your code.
- A plain-English note on every step: which variable changed, which function was called, what it returned.
- The call stack as cards, so recursion is easy to follow: every call is numbered and shows its own variables.
- Vectors and arrays as indexed boxes, maps as tables and objects with their fields, with arrows from each pointer to what it points to.
- When the code fails, the error explained in simple words, with a button to jump to the step where it happened.
- Play, pause, go back and forward, or drag the slider. Works on phones too.
What it supports
C++20 (GCC 14) in your browser
- C++ with the whole standard library: string, vector, map, set, algorithm and more.
- If something is wrong, the error tells you the line and what to fix in plain words.
- Type what cin reads in Input; what cout prints appears in Output.
- Runs stop after 5 seconds, so a loop that never ends cannot freeze anything.
- Your code stays in your browser. Nothing is kept on our servers.
Input
How to read input in C++
Programs that read from the keyboard get their input from the Input box. Type one value per line, then press Run. The program reads the lines in order, just as it would from a keyboard.
int n; cin >> n; // first number string word; cin >> word; // next word string line; getline(cin >> ws, line); // a whole line
Tip: if the output is empty or the run stops after 5 seconds, the program may be waiting for input that is not in the box.
Questions
Frequently asked questions
Do I need to install a C++ compiler to use this?
No. Your code is compiled with GCC (g++, C++20) and run on our servers, so a browser on a laptop or a phone is enough. Later, install GCC or Clang on your computer for bigger projects.
How do I read input in C++ here?
Type the input in the Input box, one value per line, and read it with cin >> or getline(cin, line). The whole box is given to your program as standard input when you press Run.
Can I use the STL?
Yes. The whole standard library is there: vector, string, map, set, unordered_map, algorithm, ranges and more. The code visualizer draws vectors, maps, sets and strings as they change.
Learn
Learn C++ step by step
Press Visualize on any program to watch it run line by line: the fastest way to understand loops, functions and objects.