C++ Playground
Compile and run C++ in your browser with a WASI Clang toolchain, prepared standard input, console output and coding examples.
C++ code
Press Ctrl/Cmd + Enter to run. Auto-run reruns 700 ms after editing. Enable Monaco for highlighting; it loads from a CDN only when requested.
The browsercc 0.1.1 Clang/LLD toolchain downloads from jsDelivr on the first Run — roughly 26 MiB compressed for clang.wasm, lld.wasm and the sysroot. Code is compiled to WebAssembly, then run in a fresh Worker. Prepare standard input before Run; there is no live terminal. C++ exceptions and threads are unavailable in this WASI toolchain. Runtime notices.
Code examples (20)
Click an example to replace the editor with a complete program. Auto-run is paused; press Run to compile and execute it.
Basics
Number exercises
Logic exercises
Arrays and search
Functions and OOP
Star patterns
Output
Read the prepared input with std::cin or std::getline. Runs in a Web Worker, without direct DOM access. Stop terminates execution; each run has a 30-second execution limit and output is capped at 500 rows. Code can still make network requests, so only run code you trust. The tool does not save or upload your code or input.
Learn
About this tool
Compile C++20 to WebAssembly in a disposable browser Worker with the browsercc 0.1.1 Clang/LLD toolchain. The compiler and sysroot download from jsDelivr only on Run or when Auto-run is enabled. Exercises cover arithmetic, logic, containers, classes and pyramid patterns. Code and input are not saved or uploaded by the tool. Compiled code can still make network requests through WASI; only run code you trust.Questions
- How do I read input?
- Fill Standard input before Run, one answer per line, then use std::getline or std::cin. std::getline drops the trailing newline for you. If the stream is empty, getline returns false. This is prepared input, not a live terminal.
- Why does the first Run take longer?
- The Clang compiler, linker and sysroot download from jsDelivr on the first Run — roughly 26 MiB compressed. Runtime loading has a 90-second timeout, followed by a separate 30-second execution limit. Later Runs in the same page reuse the loaded toolchain.
- Can I use exceptions, threads or the full standard library?
- No. The WASI libc++ is built without exceptions or threads, and this runner compiles with -fno-exceptions. Code that relies on throwing or catching will not link. Most of the standard library for console programs, including string, vector and map, works.
- Does selecting an example erase my code?
- Yes. C++ examples are complete programs with their own main, so clicking one replaces the editor and pauses Auto-run. Copy anything you want to keep first.
- Is this a security sandbox?
- No. A Worker prevents direct DOM access and can be terminated, but compiled code can make network requests through WASI. The tool itself does not upload or persist code or input. Each Run starts fresh; output is limited to 500 rows.