RUN

C++ Online Compiler

Write, compile and run C++ in your browser. Free, no sign-up.

main.cpp

// Welcome to the CodingHumans C++ compiler.
// Press Run (or Ctrl + Enter). Your program asks for input in the output panel.

#include <bits/stdc++.h>
using namespace std;

int main() {
    string name;
    int n;
    cout << "What's your name? ";
    cin >> name;
    cout << "How many numbers? ";
    cin >> n;

    vector<int> squares;
    for (int i = 1; i <= n; i++) squares.push_back(i * i);

    cout << "Hello, " << name << "! Squares: ";
    for (int s : squares) cout << s << ' ';
    cout << "\nTheir sum is " << accumulate(squares.begin(), squares.end(), 0) << '\n';
}
Output

Press Run to see the output.

C++ examples to try

How to run C++ online

  1. Write or paste your C++ code in the editor.
  2. Press Run, or Ctrl + Enter (Cmd + Enter on a Mac).
  3. If your program reads input with cin, type it in the output panel and press Enter.
  4. Press Share to copy a short link to your code. Anyone who opens it sees exactly what you wrote.

About this C++ compiler

This free C++ compiler uses Clang, a real C++ compiler, running inside your browser. Your program is compiled to WebAssembly and runs on your own computer, so there are no queues and no run limits. It compiles as C++20 with optimisations on.

The full standard library works: vector, map, set, unordered_map, string, algorithm, priority_queue and more. #include <bits/stdc++.h> works too, so competitive programming code runs as it is. cin waits for you to type in the output panel while your program runs, like a real terminal.

Errors and warnings come straight from the compiler, with the line and column. If your program crashes, for example by going past the end of an array, you see a plain explanation. Press Stop to end a program that never finishes.

Frequently asked questions

›Is this C++ compiler free?

Yes. It is free with no sign-up and no run limits. The compiler runs in your own browser, which is what keeps it free.

›Which compiler and C++ version is it?

Clang 22 with the libc++ standard library, compiling C++20 with -O2. Code written for g++ compiles here too, and #include <bits/stdc++.h> works.

›Do exceptions (try, catch, throw) work?

Not yet. The browser build of the C++ library has no exception support, so code with try, catch or throw shows a compile error. Everything else in the standard library works.

›Why is the first run slow?

The first time, your browser downloads the compiler and a ready-made copy of the C++ standard library headers (about 42 MB in all). Both are cached after that, so later programs compile in about a second.

›What can’t it do?

Your program runs in a sandbox: there are no files, no network and no threads. Headers from other systems, such as conio.h or windows.h, are not available.