In Golang, we are allowed to use
go run main.go to compile and execute the the source file in one step. But in C++ by default, we need to compile first then perform execution.
We can crete a shell script to let C++ working like Golang.
Setp 1 .
Creating a script to a
bin directory named
cpprun. Such as
Step 2 .
Adding the following contents to
#!/bin/csh g++ -std=c++11 -o /tmp/a.out $1 && /tmp/a.out
Step 3 .
Run the cpp file.
$ cpprun main.cpp