C Programming Ca1-1
C Programming Ca1-1
Presentation on:
HEADER FILES IN C
Paper name:Programming for Problem
Solving
Paper code:BCAC102
Department of BCA
Presented by:
Debamita Sinha
Roll no.-
184297
INTRODUCTION
• In C programming,header files are used to declare
functions, macros and variables that can be shared
across multiple source files.
• A header file typically has a .h extension and contains
declaration of functions and data structures,which
allows these components to be used in other source
files by including the header.
Click icon to add picture
In C programming,there are various types of header
files. Here are some of the most commonly used header
files in C:
• <stdio.h>
• <conio.h>
• <string.h>
• <math.h>
2
THE PURPOSE
OF HEADER
FILES
ORGANIZATION
They organize code by separating
declaration from definitions,
promoting modularity and reducing
code redundancy.
REUSABILITY
Header files enable code reuse by
providing access to pre-defined
functions and data structures. This
saves time and promotes consistent
code.
COMPILATION
They provide the compiler with
necessary information to veriy the
correctness and consistency of
function calls and variable usage
within a program.
STANDARDIZATION
Use pre-defined library to save time
as well as effort in C programming.
<stdio.h>
The #include<stdio.h> directive is commonly used in C programming as it includes
the standard input-output header file(stdio.h),which contains essential functions like-
1.printf()-
Prints textlines or strings and values of different variables.
2.scanf()-
Used to take input values from the user of different data type.
3.puts()-
Displays a string or texts only. We cannot print values of variables using puts().
4.gets()-
Used to get/input string from the user.
5.putchar()-
Prints a character to the standard output stream.
6.getchar()-
Reads a character from the standard input.
7.fflush(stdin)-
Used to flash out the memory buffer.
1strlen()-Used to count the number of characters in a string without null character i.e. the
length of the string.
2.strcpy()-Used to copy one string to another.
3.strncpy()- Used to copy first n characters of one string to another.
4.strcmp()-Used to compare two strings(case sensitive).
5.strcmpi()-Used to compare two strings(case insensitive).
6.strcat()-Used to concatenate or merge two input strings.
7.strncat()-Concatenates first n characters of one string to another.
8.strrev()-Used to reverse a string. .
9.strlwr()- Converts a string to lowercase.
10.strupr()-Converts a string to uppercase.
11.strpdup()-Duplicates a string. .
6 Presentation title 20XX
EXAMPLE PROGRAM
USING <string.h>