Library Functions in C - C tutorials
Library Functions ::-
C language has lot of valuable library functions which is used to carry out some tasks
for instance printf function is used to print output on screen.
The built-in functions known as library functions are gathered in one place and given the name library.
Here, each function carries out a certain action. To obtain the pre-defined output, we can use the library functions.
Many header files are used to declare every function in the C standard library. These library functions were developed when compilers were being designed.
Using #include<filename.h>, we include the header files in our C application. The relevant files are added to the C program each time it is run and executed.
Features of Header Files:-
The following are a few of the header file's functions:
The standard input/output header file, stdio.h, contains declarations of input/output functions.
the conio.h This file is an input/output header for the console.
All functions relating to strings can be found in the header file string.h.
STD LIB.H Common functions that are used in C programmes can be found in this file.
math.h − This header file contains all math-related functions.
time.h − The functions relating to time and the clock are in this file. constructed in stdio.h
Ex. printf("%d",i);
Constructed in stdio.h :-
👉%d for integer
👉%f for float or real value
👉%c for character
C output functions :-
For performing output operations, the C programming language includes built-in functions. Data is shown using output procedures on a user screen (output screen), a printer, or in any type of file. The following built-in output functions are available in the C programming language.
On the output screen, the printf() function is used to print strings, data values, or a combination of strings and data values (User screen). The "stdio.h" header file contains a built-in function called printf(). The #include declaration must be used to include the appropriate header file (stdio.h) when utilising the printf() function in a programme. The syntax for the printf() function is as follows:
Syntax :-
printf("welcome in my blog!!");
Receiving input from user ::-
C Input Methods :-
Scanf Function :-
To read several data values of various data kinds from the keyboard, use the scanf() function. The "stdio.h" header file contains the definition of the built-in scanf() function. When using the scanf() function in our programme, we must use the #include command to include the corresponding header file (stdio.h).
In order to get input from user and assign it to variable we use scanf function.
syntax :-
scanf("format strings",&variableNames);
Note : - & is "address of" operator assign to variable.
getchar() function :-
A character from the keyboard is read and returned to the programme using the getchar() function. One character can be read using this function. We must either write several times or use a looping statement to read multiple characters.
getch() method :-
Similar to the getchar function is the getch() method. A character from the keyboard is read and returned to the programme using the getch() method. One character can be read using this function. We must either write several times or use a looping statement to read multiple characters.
gets() function :-
To read a line of text and store it in a character array, use the gets() function. The gets() function reads a line of characters or a string until a newline symbol appears.
fscanf() function :-
With the idea of files, one uses the fscanf() function.the fscanf function is used to read data from file. when we used fscanf() function file must be in reading mode.
Post a Comment