Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save NateWeiler/33e51a6d9e682503930dd876186a29ef to your computer and use it in GitHub Desktop.
Save NateWeiler/33e51a6d9e682503930dd876186a29ef to your computer and use it in GitHub Desktop.
GCC / Clang C/C++ Compiler On Android Using Termux (Linux Environment)

Install Termux App

apt update && apt uprade -y

We have to install the nano text editor to write our code.

apt install -y nano

Clang Installation.

apt install -y clang

Create a file.

nano hello-world.c

or

nano hello-world.cpp

Write your code.

#include <stdio.h>
int main() {
   // printf() displays the string inside quotation
   printf("Hello, World!");
   return 0;
}

write ctrl o to save ur code simply press esc then type

The code is ready to compile

type

clang hello-world.c -o hello-world

It will compile; or it will show error. If it errors you have to fix it.

Now you have to make the file executable.

chmod u+x 0777 hello-world.c

To run your program type

./hello-world
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment