C++ Programming

Terminal Guide & Documentation

C++ Programming

1. Introduction & Use Cases

C++ is a powerful, high-performance programming language used for system/software development and competitive programming. In Termux, C++ allows you to build lightning-fast utilities and exploit proof-of-concepts.

  • System Programming: Building low-level tools that interact with the Linux kernel.
  • Performance: Developing resource-intensive applications like scanners or crackers.
  • Game Development: Using libraries like SDL2 or SFML (via X11).
  • Cybersecurity: Writing memory-efficient exploits and security tools.

2. Basic Syntax & Variables

C++ is a statically typed, compiled language. To install the compiler in Termux, use pkg install clang.

bash — main.cpp
#include <iostream>
#include <string>

int main() {
    std::string platform = "Termux Hub";
    int year = 2026;
    
    std::cout << "Welcome to " << platform << std::endl;
    std::cout << "Academy Year: " << year << std::endl;
    return 0;
}

3. Control Flow & Functions

Structured programming with loops and conditional logic in C++.

bash — control.cpp
#include <iostream>

void checkPort(int port) {
    if (port == 80 || port == 443) {
        std::cout << "Port " << port << " is standard web port." << std::endl;
    } else {
        std::cout << "Port " << port << " is a custom port." << std::endl;
    }
}

int main() {
    int ports[] = {80, 8080, 443};
    for(int p : ports) {
        checkPort(p);
    }
    return 0;
}

4. Core Commands Cheat-sheet

  • g++ -o output file.cpp - Compile a C++ file.
  • ./output - Run the compiled binary.
  • pkg install clang - Install the C++ compiler.
  • std::cin >> var; - Get user input.
  • std::cout << var; - Print to console.

5. Popular Libraries & Frameworks

  • STL: Standard Template Library for data structures and algorithms.
  • Boost: A massive set of high-quality peer-reviewed libraries.
  • POCO: Powerful C++ class libraries for network-centric applications.
  • OpenCV: Real-time computer vision library.
  • Crow: A fast and easy-to-use micro web framework for C++.

6. Advanced Practical Example: File Reader

A C++ program that reads and displays the content of a file, simulating a basic 'cat' command.

bash — reader.cpp
#include <iostream>
#include <fstream>
#include <string>

int main(int argc, char* argv[]) {
    if (argc < 2) {
        std::cout << "Usage: ./reader [filename]" << std::endl;
        return 1;
    }
    
    std::ifstream file(argv[1]);
    std::string line;
    
    if (file.is_open()) {
        while (getline(file, line)) {
            std::cout << line << std::endl;
        }
        file.close();
    } else {
        std::cout << "Unable to open file" << std::endl;
    }
    
    return 0;
}

Explore More Tools

Python

Master automation and security scripting.

JavaScript

Build interactive web tools with Node.js.

Nmap

Network discovery and security auditing.

Explore Termux Hub

Kali Toolkit

Toolkit home (145 scripts) Foundations Network recon Defensive monitoring Vulnerability scanning Enumeration System hardening

Termux tool guides

Apache Brutus Cloudflare Cool Commands Cpp Findomain Fsociety Geo Recon Ghost Eye Hacktronian Ipicker Javascript John Local Server Manjaro Naabu Ncat Nmap Nordvpn Onex Pydictor Python Quasar Recondog Subfinder Termux Banner Ubuntu Gui Wafw00F Web Recon

Learn

Home Termux cheatsheet Python JavaScript C++ Cool Termux commands About Termux Hub