01 logo

DAY 03 : FILES USED IN C PROGRAM

#100DaysCodeChallenge

By Preethi SivaPublished 2 years ago 3 min read
1

A C Programming language is a versatile language equipped adequately with a number of files. Every C program in mandatory is associated with four different types of files. The files are as follows.

1. Source file

2. Header file

3. Object file

4. Executable file

SOURCE CODE FILES :

The source code file, as the name suggests, holds the actual code in it. The file extension for this type of file is '.c' extension. This file primarily defines the main() function and others functions if any. We already know that the entry point or the starting point of execution of a C program is the main() function. The prominent fact that is worth mentioning here is that, a source file in C program may have other source code files also in it provided the other file included has the file extension as '.c' extension.

HEADER FILES :

Header files are the most necessary files in a C program that plays a pivotal role. Header file includes all the sub programs, the so called sub routines. The file extension for a header file is '.h' extension. This type of header files are useful while working with large projects, where it is often advised, from the main() function to divide into many sub routines for easy maintainability. We may come across a situation to use the same sub program in many places while working with enormously huge codes and projects. So creating a sub routine will lend its helping hands in those situations. We also have another option, that is to copy the sub code and paste it in every place that we require. But that paves way for too many errors which is difficult for a service provider to handle and rectify. Since, copying is a tedious process as well as error prone, it is considered inefficient. The best way is to make header files out of the sub routines created. There are many advantages in using header files. There are two various categories in a header file, namely:

1. Standard header file

2. User-defined header file

STANDARD HEADER FILES:

A C program, on its own has many standard header files (say for example, stdio.h, conio.h) well equipped with lot of functions like printf,scanf etc. The fact is that we do not know the logic or the idea on how these functions work. We have the liberty only to input the values and visualize the output alone.

The various standard header files are mentioned below along with their purpose.

string.h = handling string functions

stdio.h = standard input output functions

stdlib.h = some other various functions

math.h = mathematical functions

OBJECT FILES :

The codes are written in high level language. In this case, a compiler comes into play. The work of a compiler is to convert the code of a high level language to an assembly code. As a result of the process of compilation and processing the source code file, an object file is created. The mode of this type of file is binary mode, that is all the function definitions are in the form of zeros and ones (0 1). Hence after an object file is created, the linker is used to combine the object files together and produces an executable file. Object files have the file extension as '.o' extension. 

EXECUTABLE FILES :

As said earlier, after an object file is created, the linker comes into action and combines the object files together to produce an executable file. An executable file is a culmination of many object files together. Hence, it is also known as 'Binary executable files'. These type of files can be directly executed. The file extension of an executable file is '.exe' extension.

how to
1

About the Creator

Preethi Siva

Writing is not my hobby.........

It comes when my heart is connected to my soul and says to write!!!

Reader insights

Be the first to share your insights about this piece.

How does it work?

Add your insights

Comments

There are no comments for this story

Be the first to respond and start the conversation.

Sign in to comment

    Find us on social media

    Miscellaneous links

    • Explore
    • Contact
    • Privacy Policy
    • Terms of Use
    • Support

    © 2024 Creatd, Inc. All Rights Reserved.