Before we get to more complex IDEs, let’s explore repl.it which allows you to write programs and execute programs in your browser. You can, but do not have to, create a repl.it account.

Click on “start coding”, choose “C++” as your language and create your first repl.it

  repl.it creates the default “Hello World” program. You can compile and run it by clicking on the “play” button (green arrow).

When you compile and run it, repl.it shows you the unix commands it is using. The default for C++ programs is:

$ clang++-7 -pthread -std=c++17 -o main main.cpp
$ ./main  

The default compiler on repl.it is clang++-7. You can also type directly into the shell area to compile your program using a different compiler. Try compiling your program using g++ by typing

$ g++ -o main main.cpp

Other unix commands, such as ls, which, rm, etc, are also available in the shell provided by repl.it.

The repl.it interface is intuitive and sufficient for small programs. More advanced repl.it commands are available through a hidden menu. Use CTRL-Shift-P (Windows) or Command-Shift-P (Mac) to open the repl.it Command Palette.

You can add a link to your README.md file, something like https://repl.it/github/GitHubUSERName/projectname which will with one click import the GitHub repository to repl.it and allow anyone to run it.

A repl.it hack: Currently (Jan 2020), the auto-format function on repl.it is broken, so you cannot re-indent code easily. You can however use clang-format from the unix shell to re-format the file that has bad indentation. This trick can be used on any system where you have clang-format installed.

clang-format -i main.cpp