C is a powerful General Purpose Programming Language. Learning C could be beneficial as it is one of the basic but powerful language, there are several powerful tools which had been developed using C. The Python interpreter is written in C language known as CPython, Linux OS was built using C, Android Kernels , MacOS and even Crunch a pentest password word list generator tool is built using C language.
The Installation is complete.
Now, we must know how to use these applications/tools.
If you encounter any error there's is something wrong with the program.
So to start with C programming, a newbie must have an Integrated Development Environment(IDE).
It would be so difficult to write in a notepad. IDE can make things much simpler, makes every task like Compiling, Linking, Debugging easy to perform. Without an IDE it would be difficult for developer to mange a project.
There are several IDE's for Windows, but the two popular ones are listed below with print screen:
1. Dev C++
Dev C++ |
Download link: https://www.bloodshed.net/devcpp.html
2. Codeblocks
Codeblocks |
Download link: http://www.codeblocks.org/downloads/binaries#windows
But the colleges and Universities prefer using Borland Turbo C++
Borland Turbo C++ |
Download link: https://anonymousfiles.io/xc5B2G2b/
But when we come to Android Devices. There are very few IDE's that follow C rules of Dennis Ritchie. Hence, this blog focuses on how to start programming on Android devices in C.
There are several ways to install Borland Turbo C++ IDE on Android. But in this post, we'll use Termux (an Android terminal emulator and Linux environment app that works directly with no rooting or setup required).
Play Store Link: https://play.google.com/store/apps/details?id=com.termux&hl=en_IN
Installation:
1. Install Termux from Play Store.
2. On first start, Termux will take to start as dependencies are being installed.
Note: Do not interrupt while installing on first start.
3. After you get the screen as shown in screenshot. Type or Copy-Paste the Command in Termux below.
Note: During Installation of any script here, if you are prompted 'Do you want to continue[Y/n]', Enter Y and press Enter/Send on keyboard.
$ apt-get update
Output should be something like this |
4. For installing vim(editor) for terminal. Use
$ pkg install vim
vim had been successfully installed |
5. The last step for installation is to install the clang(compiler).
$ pkg install clang
clang after installation |
Now, we must know how to use these applications/tools.
How to use:
Before starting you should be aware of basic terminal commands, some of them are as follows
i. make directory:
Syntax: mkdir directory_name
example: mkdir C_Programs
ii. list:
This command is used to list of files in the directory in which we are working.
example: ls
(this will print all the files in current directory)
iii. change directory:
Syntax: cd directory_name
example: cd C_Programs
(this will change my directory which we have created named as C_Programs)
iv. remove file:
Syntax: rm file_name
example: rm Hello.C
(Hence, Hello.C C file will be removed)
v. touch command:
This command will create a empty file.
Syntax: touch file_name
example: touch temp.c
(Self Explanatory)
vi. vim commands:
:e filename | Open filename for edition |
:w | Save file |
:q | Exit Vim |
:q! | Quit without saving |
:x | Write file (if changes has been made) and exit |
:sav filename | Saves file as filename |
. | Repeats the last change made in normal mode |
Steps:
1. Create a directory in terminal.(This step can be skipped)
using mkdir command.
$ mkdir C_Programs
ls command can be used to view the directory.
2. Changing directory to C_Program:
$ cd C_Programs
/ is optional |
3. Creating an empty c file:
$ touch temp.c
The empty file can be viewed using ls command |
4. Using vim editor to write a C program:
$ vim temp.c
Press Send/Enter/Return key to edit and write a program |
5. Editing the file:
After Editing |
Empty C File |
To Save the edited file, Press Esc, then type :x to save and exit the file.
6. Compiling The file:
To compile the file use gcc command followed by the filename then -o(output file) followed by <output_filename>
Syntax: gcc file_name -o ouput_file_name
$ gcc temp.c -o temp
File has been successfully compiled |
You can view compiled file using ls command.
temp green colored file is the compiled file |
7. Executing the compiled file:
To execute the compiled file simply type ./filename
Syntax: ./file_name
Example:./temp
Successfully Executed..
Explore C in Termux.
Comments
Post a Comment