How to run c program in termux in android
C program
C in termux
C in android
1 minute read
What is C
C is a general-purpose, imperative computer programming language, supporting structured programming, lexical variable scope and recursion, while a static type system prevents many unintended operations.
How to install C ?
Open termux and type following command
• > pkg install clang
You can use any text editor according to your comfort in this tutorial I am using nvim
To install nvim in termux type this command
• > pkg install nvim
To write your program first you have to create a file , you can create a file using this command
• > touch filename.c
Here filename may be anything according to your wish example hello.c
After that open your file in editor using this command
• > nvim filename.c
We write a simple c program in "C" language
#include <stdio.h>
int main()
{
printf("Hello, World!");
return 0;
}
Now press ESC then :wq to save your file in nvim , same is applicable for vi and vim also and if you are using nano text editor then press ctrl + s to save your file
To compile your program type this command
gcc filename.c -o filename
For example Above we have created a file named as hello.c
To compile this c program we will write command > gcc hello.c -o hello
After that execute your program using this command
./filename
In this tutorial Our filename is "hello" so we will use command ./hello to execute it
You have created your first program in c aud run it in android well
Thankyou guys :)