![]() In your Terminal, enter the following command in order to make an executable version of the program you have written: Step 3: Compile the C program with gcc Compiler c file where you can write and save a program. In this example, I am naming my C program as sampleProgram.cĪlternatively, you can write the C program through the Terminal in gedit as follows: $ gedit sampleProgram.c Open Ubuntu’s graphical Text Editor and write or copy the following sample program into it: #include Step 2: Write a simple C programĪfter installing the essential packages, let us write a simple C program. Please make sure that you are connected to the internet. You will be asked to enter the password for root the installation process will begin after that. Enter the following command as root in your Linux Terminal: $ sudo apt-get install build-essential In order to compile and execute a C program, you need to have the essential packages installed on your system. Step 1: Install the build-essential packages To open the terminal, you can use the Ubuntu Dash or the key combination Ctrl+Alt+T. To compile a simple C program, we use the Linux command-line tool, the terminal. ![]() ![]() We have run the steps and commands mentioned in this article on an Ubuntu 22.04 LTS system, but it works exactly the same on other versions like Ubuntu 20.04 or on Debian 11. ![]() This will serve you as a foundation to move on to more complicated and useful C programs that you can write and run on Linux. In this article, we will explain you how to write, compile and run a simple C program on Ubuntu Linux. Linux is a developer’s paradise because it is an open-source operating system, freely available and offers free programming tools for all popular programming languages. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |