Hello, World!
#include <iostream>
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}Tap Run to execute
main.cpp · output appears here
Press Run to execute
Output streams here as your program runs.
C++ is a statically typed, multi-paradigm language created by Bjarne Stroustrup at Bell Labs, beginning in 1979 as C with Classes and renamed C++ in 1983. It extends C with object-oriented programming, templates for generic code, RAII-based resource management, and a rich Standard Template Library. C++ aims to give high-level abstractions with little or no runtime overhead.
Today C++ powers game engines, high-frequency trading, browsers, databases, and other performance-critical software. Modern standards from C++11 onward added smart pointers, lambdas, move semantics, and more, making the language safer and more expressive. CompileBytes builds main.cpp with GCC 15.3 in C++20 mode inside an isolated hosted sandbox, so you can use concepts, ranges, the STL, templates, and other modern language features without installing a toolchain.
main.cpp is the entry point. Add helper files from the explorer and import them into your project.
Use the Input panel to pipe standard input to your program when it needs data.
Run sends your code to a fresh hosted runtime and streams the result into the output panel.
Your draft stays in this browser, and Share creates a separate snapshot link.
main.cpp includes a header containing an inline helper definition.
#include <iostream>
#include "helper.hpp"
int main() {
std::cout << answer() << "\n";
}
#ifndef HELPER_HPP
#define HELPER_HPP
inline int answer() { return 42; }
#endif
#include <iostream>
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}#include <iostream>
#include <string>
int main() {
std::string name;
std::getline(std::cin, name);
std::cout << "Hello, " << name << "!" << std::endl;
return 0;
}#include <iostream>
#include <vector>
int main() {
std::vector<int> nums = {10, 20, 30};
for (int n : nums) {
std::cout << n << std::endl;
}
return 0;
}#include <iostream>
long factorial(int n) {
return n <= 1 ? 1 : n * factorial(n - 1);
}
int main() {
std::cout << factorial(5) << std::endl;
return 0;
}#include <iostream>
#include <stdexcept>
int main() {
try {
throw std::runtime_error("something failed");
} catch (const std::exception &e) {
std::cout << "Caught: " << e.what() << std::endl;
}
return 0;
}#include <iostream>
#include <map>
#include <string>
int main() {
std::map<char, int> counts;
for (char c : std::string("banana")) {
counts[c]++;
}
for (auto &[ch, n] : counts) {
std::cout << ch << ": " << n << "\n";
}
return 0;
}#include <iostream>
#include <vector>
#include <algorithm>
int main() {
std::vector<int> nums = {3, 1, 2};
std::sort(nums.begin(), nums.end());
for (int n : nums) std::cout << n << " ";
std::cout << "\n";
return 0;
}#include <iostream>
#include <string>
class Person {
public:
std::string name;
int age;
Person(std::string n, int a) : name(n), age(a) {}
void describe() const {
std::cout << name << " (" << age << ")\n";
}
};
int main() {
Person p("Ada", 36);
p.describe();
return 0;
}#include <iostream>
template <typename T>
T maxOf(T a, T b) {
return a > b ? a : b;
}
int main() {
std::cout << maxOf(3, 7) << "\n";
std::cout << maxOf(2.5, 1.5) << "\n";
return 0;
}#include <iostream>
#include <vector>
#include <algorithm>
int main() {
std::vector<int> nums = {1, 2, 3, 4, 5};
int count = std::count_if(nums.begin(), nums.end(),
[](int n) { return n % 2 == 0; });
std::cout << "Evens: " << count << "\n";
return 0;
}The editor uses Monaco, the engine behind VS Code, with language-aware editing tools and familiar keyboard controls.
Type or paste your code into the editor, then click Run (or press Ctrl/Cmd + Enter) to execute it.
Output streams into the console panel, including runtime errors, exit status, and execution time.
Nothing to install and no account to create — code runs in an isolated hosted runtime.
Language-aware autocomplete and IntelliSense suggestions where the editor has a matching language service
Syntax highlighting, with native compiler and runtime errors shown in the console
Bracket matching, auto-indentation, code folding, and a minimap
Multi-cursor editing plus find & replace (Ctrl/Cmd + F)
Full undo/redo history and copy to clipboard
Built on Monaco — the same editor that powers VS Code
Run on demand, or turn on Auto-run to execute on every change
Stop long-running or infinite programs at any time
A real console shows standard output, errors, exit status, and execution time
Pass standard input (stdin) to your program from the Input panel — one value per line
Switch between light and dark themes
Adjust font size and other editor settings
Toggle side-by-side or top/bottom layouts
Enter distraction-free fullscreen mode
Generate a shareable link to your exact code in one click — no login needed
Your work autosaves to your browser, so you can pick up where you left off
Copy the active file to your clipboard
Run code: Ctrl/Cmd + Enter
Find & replace: Ctrl/Cmd + F
Open the full shortcut list from the keyboard icon in the toolbar
C++ is one of 23 linked-project compilers. Run always starts main.cpp; selecting a helper tab changes what you edit, not the entry file.
main.cpp includes a header containing an inline helper definition.
Linked-project languages (23): Node.js, TypeScript, Deno, Python, C, Go, Dart, Swift, Rust, Ruby, PHP, Java, Kotlin, C++, C#, Nim, Crystal, Haxe, Zig, Scala, D, Bun, Objective-C.
Single-file scratchpads (46): Matplotlib, NumPy, pandas, Haskell, Clojure, Perl, Lua, Tcl, jq, Raku, Elixir, Bash, Zsh, Nushell, R, Assembly (NASM), Julia, Octave, Groovy, PowerShell, Visual Basic .NET, Odin, Pascal, Lisp, Erlang, CoffeeScript, COBOL, BASIC, V, Racket, OCaml, Prolog, AWK, Emacs Lisp, Emojicode, Forth, F#, Fortran, Assembly (NASM64), Solidity, Mojo, Ada, WASM (WAT), Gleam, Shell Script (sh), Scheme. Their extra project files are not submitted to the runtime.
Download project exports every C++ tab and a README in one ZIP archive.