Hello and welcome in today's session.
We will discuss on library function and system calls.
All programs explained in this course are mostly in C.
Ubuntu pc is used to run c program.
User can use any linux distribution.
GCC compiler is used to compile the code.
The C library functions or the C standard library.
The C standard library are also called as LIBC.
The C Standard library also provides header files that needs to be included in users application program.
In order to use the standard library function calls.
The library is a collection of pre compiled code.
The library contains several functions together and they form a package or a library.
The library helps to reuse the code by avoiding same code again and again.
For example, the standard C library provides standard stdio.h header file, and this header file needs
to be included in the user program in order to use the library function.
Printf().
Some library functions are designed over the system calls in order to provide more additional functionality
in library functions.
We will discuss this after learning system calls.
In this diagram.
It shows the interface between the application software and the C standard library.
The application software calls the standard library function, and the function performs the action
and returns the data back to the application software.
In some cases the standard library function call.
Can in-turn, call the system call if required to access the hardware.
Now we will see the demo how to use the standard library function in a C code.
Also, we will see the compilation of our first C program in Linux environment.
In this folder, we have created a simple C program called lib_ex.c
Vi is the editor used.
You can use any other editor of choice.
This is a sample program to use the standard library.
stdio.h is the standard input and output header file.
Printf is the standard library function which is used to display the user defined string on the screen.
Now.
In order to compile the source code, we use GCC.
The command to compile the source code is GCC.
Followed by the name of the source code, followed by .
-o
Here -o represents object file, followed by the name of the output file.
Now.
We have created an output file called lib_ex.
This file can be executed by running
'./Lib_ex'.
We can see that the output is printed on the screen.
The string that we used in the printf() of the program is used to display on the screen.
Hence we can conclude that library function printf() in this case is used to display string on the screen.
In order to use library function, we need to include corresponding header file.
In next session, join me.
We will discuss on system calls.
Thank you.