C/C++ On Android With Termux In Few Easy Steps

    Installing C/C++ on android can be beneficial cause you can learn C or C++ programming even though you don’t have a desktop. It can also be beneficial if you have to run or test some code and your laptop or PC is not available at that moment. No matter what we always have our android phone with us. So setting up C/C++ on android is beneficial, that’s why in this article I’m going to tell you how you can set up C/C ++ on an android phone with the help of the termux application. Follow the steps given below to install C or C++ in android.

    c++ in android

    What Is Termux Application ?

    A termux is an android terminal emulator that you can use to run so many Linux packages on an android phone without root. You can download termux by clicking here. To know more about the termux application click here.

    After you have successfully downloaded and installed the termux application open it and then type the commands given below to set up the C/C++ environment in your phone.

    C/C++ On Android With Termux

    Open your termux application and type the following commands:

    • Update and Upgrade the packages.,
    apt update && apt upgrade
    • Install nano and clang package in termux applicaiton.
    apt install nano clang -y

    Run VS Code On Android In 3 Amazing Simplest Steps

    Writing and running C/C++ programs in android with Termux

    Now that we’ve installed everything that is required to run C/C++ programs on android, let’s write a C program in termux with the help of nano text editor.

    • Create a C/C++ file using nano text editor. I’ll be creating a simple hello.c file.
    nano hello.c
    • Write the code that you want to write and then save it using Ctrl + O and then exit nano text editor using Ctrl + X.
    c++ in android - writing simple c program
    • Now to compile C/C++ code using gcc. To compile C code I have to use gcc but for C++ I have to use g++ and then the file name.
    gcc hello.c
    • Now if you’ll do ls, you’ll see a file named a.out run that file using ./a.out command to run your C/C++ program.
    c++ on android

    Easy Steps To Install Kali Nethunter In Android Without Root


    So this is how you can write and run C/C++ in android with the help of the termux application. If you got stuck somewhere during the installation process don’t forget to watch the video given below.

    Recent Articles

    Leave A Reply

    Please enter your comment!
    Please enter your name here