Buy C++ Books

A Tour of C++ (C++ In-Depth Series)


Category: C++

Added: 17th of October 2020

Viewed: 122 times

Create a simple c++ script using Ubuntu and other Ubuntu based distributions

This tutorial works in Ubunbu, Kubuntu, Xubuntu, Lubuntu, Ubuntu Mate and other Ubuntu based distributions. The tutorial also works in Linux Mint and other Debian based distributions.

To create a simple C++ script in Ubuntu and other Ubuntu based distributions do the following

C++ should already be installed in your distribution, to check open your terminal and enter the following command

which cpp


If installed it will show you the path to cpp
/usr/bin/cpp


If C++ is not installed in your distribution, there will be no output from the terminal.
In this case we need to install C++, so please enter the following in your terminal
sudo apt-get install cpp


Once installed, we can now write and compile our first C++ script that will be executed through the terminal.

Create a new file on your desktop named myfirstscript.cpp
If not obvious the .cpp extension refers to c++

Open the file you just created in your distributions text editor, then copy and paste the code below.

#include <iostream>
int main ()
{
std::cout << "Hello, Welcome To My Computer Tips" <<std::endl;
return 0;
}


Next we need to compile and create an executable file.
Open your terminal and enter the following command
g++ myfirstscript.cpp -o myfirstscript


Next we need to run the script
./myfirstscript




Other Tips & Tutorials

C++

Install Visual Studio Code in Kubuntu, Ubuntu and Ubuntu based distributions. Compile and execute C++ script

Posted: 18th of October 2020

Views: 136

C++

Create a simple c++ script using Ubuntu and other Ubuntu based distributions

Posted: 17th of October 2020

Views: 122