C++ in Termux – Installation & Usage Commands

C++ is a popular programming language used to create fast and powerful programs. It is widely used for building software, games, and system applications. It is a great choice for beginners who want to learn how programs work and improve their coding skills. It also helps you understand the basics of computer programming in a clear way.

Installation Commands

Update Termux and install C++ compiler (clang):

pkg update && pkg upgrade && pkg install clang -y

Check installation:

clang --version

Usage Commands

Create a C++ file:

nano program.cpp

Write simple C++ code:

#include <iostream>
using namespace std;

int main() {
cout << "Hello C++ in Termux";
return 0;
}

Save and exit:

  • CTRL + X → Y → Enter

Compile the program:

clang++ program.cpp -o program

Run the program:

./program

Compile and run in one line:

clang++ program.cpp -o program && ./program

Compile with warnings:

clang++ -Wall program.cpp -o program

Compile multiple files:

clang++ file1.cpp file2.cpp -o output
READ ALSO  how to install hydra in termux

Leave a Comment