Many can relate to the challenge of learning a new coding language. I’ve found that quickly being able to make a first program to start experimenting with the language helps inspire the confidence needed to keep going. In this blog post I will be briefly going over the steps needed to create a simple first program in the C language in Ubuntu.
Setting Up Your Development Environment On Your Computer:
- Install your favorite text editor; mine happens to be VS Code by Microsoft.
- Know how to use the cd and ls commands in the terminal to access the files you will be creating.
C is a compiled language which means that once you have written the .c file you will need to “compile” it which will create another file which the computer will use to run the program.
To install the GCC C compiler on your computer run:
To Create Your First Program:
Create a File with the .c file extension in your text editor. Below is a sample first C file.
To Compile Your First Program:
Move to the directory that contains your program and type:
This code has two important effects, it runs the gcc compiler and creates and names an object file from your program file.
To Run Your First Program:
In the same directory, type:
Please let me know if this helped you to get started quickly with C on Linux.