Session 2 : C programming

We are going to learn programming in C in Linux with nano, the first thing that we had to do was create a directory called part-1 and there create a file with the command touch called hello_world_1.c but before we try to open it with nano we have to install obviously nano

fi1.pngNow, we are ready to open the file with nano, just type nano hello_world_1.c


First  gcc -c hello_world_1.c compiles hello_world_1.c into a machine code file named hello_world_1.o and then links hello_world_1.o with some system libraries to produce the final program hello_world_1.exe in this case


So, finally we can run this first example with ./hello_world_1.exe


Now we will create in part-1 the directory called example-02 and there create the file hello_echo_1.c


Open it with nano and type all this


Then we are going to do the same thing that we did in the first example


And finally we can run hello_echo_1


We wanted to upload to our repository in github just the files which have the code, so we create the hidden file .gitignore


with vi we type this


then we notice that we have it with the command ls -a to show the hidden files


Now in another directory called example-03 we are going to do the example 3 called hello_strings_1.c , in the picture I was wrong with the name so I renamed it with the command mv


Now type all this for the example


We have to the files .o and .exe to run our program and this will be the output


For the fourth example, we are going to do something new, create the file Makefile and also create the program called hello_structs.c


We open Makefile and type this to replace our command gcc


Now open the file hello_structs_1.c and type this



We said that with Makefile we are going to replace gcc, so now we will type make clean to remove our file .o and .exe, for that reason when we type ls -1 we have only two files hello_structs_1.c and Makefile, then with make we are going to create .o and .exe files and finally with make run we have the output of the program


And that’s all, we have to upload it in our repository 6

You can visit my repository here.


Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de

Estás comentando usando tu cuenta de Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s