h1 ENG B Terminal
h1 ENG B Terminal
ls -la
gedit
• gedit is an editor that comes built on ubuntu. We will
use it when writing the C code.
Example program in C
• Using the editor, a simple program can be written as
follows.
• The program will only print a message on the screen.
Compiling the program
• After saving the app1.c file, let's compile it using
GNU C Compiler.
• First of all, let's change the directory we are in to be
the folder where the apps1.c file is located.
• After typing gcc as below, if we run by specifying the filename,
our file will be compiled.
• The warnings that arise as a result of the compilation are
about the construction of the libraries that we did not add.
Compiling the program
• If we type ls again from the command window
and look at the files in the folder, a file named
a.out is created as a result of the compilation.
Running the program
• If we write ./a.out on the command line, the
program works as expected and prints a
message on the screen.
Removing compilation warnings
• To remove the compilation warnings, let's add
the stdio.h library, which provides the printf
function to the program, and make the return
type of the main function int.
Changing the compiled program name
• To change the name of the program we
compiled, the –o option is used as follows:
• gcc test.c -o programname
PATH variable
• When running the program, the compiled program
that we write in front of the compiled file prevents it
from being confused with the programs in the
system path.