Online C++ Compiler
Compile and run C++ code online with g++ from GCC 15. Write your program, press Run, and Online IDE compiles it and runs the result, showing compiler errors with line numbers if the build fails. Programs can read input as they run, just like in a terminal.
How to run C++ code online
- This page opens with C++ selected, so you can start typing straight away.
- Write your code in the editor, or open files from your computer: single files, or a whole project as a .zip.
- Press Run, or Ctrl+Enter. The output appears in the panel beside the editor, and when the program asks for input you type it there and press Enter.
- Share a copy with a link, or save your files to your computer.
GCC 15 (g++) on Online IDE
- Programs are built with g++ in its default C++17 mode, with the full standard library: vectors, maps, strings and algorithms.
- Every .cpp file in your project is compiled together, so classes can live in their own files with matching headers.
- Keep a single main function, in main.cpp. A second main in another file stops the build with "multiple definition of main".
Example: a C++ program that reads input
#include <iostream>
#include <vector>
int main() {
int n;
std::cout << "How many numbers? ";
std::cin >> n;
std::vector<int> nums(n);
long long sum = 0;
for (int &x : nums) { std::cin >> x; sum += x; }
std::cout << "Sum: " << sum << '\n';
}
Features of this tool
- Simple and fastA clean, lightweight editor that opens instantly.
- Powered by AceThe Ace code editor, with syntax highlighting, autocompletion and bracket matching.
- Interactive programsType input into the terminal while your program runs.
- Several filesWork in tabs, open files or a .zip from your computer, and save the project back to disk.
- Made for learningHelpful for beginners to learn and practice programs.
- Light and dark themesPlus 39 editor themes, a choice of coding fonts, and Vim, Emacs or VS Code keys.
- Keep your outputCopy or download the program output in one click.
- Share by linkSave your code in the cloud and open it anywhere.
Frequently asked questions
Which C++ compiler and standard are used?
g++ from GCC 15, in its default C++17 mode, on Linux.
How do I give my C++ program input?
Run the program, then type into the output panel when it waits on std::cin, and press Enter after each line.
Why does my build fail with "multiple definition of main"?
All .cpp files are compiled into one program, so only one of them may define main. Keep main in main.cpp and put the rest of your code in other files.
More C++ tools
Contact us
For any feedback, queries or issues, please feel free to contact us or write to . We value your input and are committed to providing the best possible experience for our users.