Header File In C Programming language

Posted by Tushar Bedekar
As We all know that in the C programming language we use to include the header files before staring the programming further. so lets view today what these header files mean to us.

As in the old programming IDE`s such as turbo c etc. we use to write as below
                          #include<stdio.h> 
#include<conio.h>        
These two are the basic header files that we usually include.There can be also different types of the header files such as<math.h>,<string.h>,<graphic.h>,<string.h>,user defined header files and many more depending on the type of the requirement in the program me written.now before moving further lets us first know what s header file.

What is Header File:-

A header file is a file with extension .h which contains C function declarations
and macro definitions and to be shared between several source files. There are two types of header files: the files that the programmer writes and the files that come with your compiler.

You request the use of a header file in your program by including it, with the C pre-processing directive #include like you have seen inclusion of stdio.h header file, which comes along with your compiler.

Including a header file is equal to copying the content of the header file but we do not do it because it will be very much error-prone and it is not a good idea to copy the content of header file in the source files, specially if we have multiple source file comprising our program.

Include Syntax:-

Both user and system header files are included using the preprocessing directive #include. It has following two forms:
#include <file>
This form is used for system header files. It searches for a file named file in a standard list of system directories. You can prepend directories to this list with the -I option while compiling your source code.
#include "file"
This form is used for header files of your own program. It searches for a file named file in the directory containing the current file. You can prepend directories to this list with the -I option while compiling your source code.

Include Operation:-

The #include directive works by directing the C preprocessor to scan the specified file as input before continuing with the rest of the current source file. The output from the preprocessor contains the output already generated, followed by the output resulting from the included file, followed by the output that comes from the text after the #include directive. For example, if you have a header file header.h as follows:
char *test (void);
and a main program called program.c that uses the header file, like this:
int x;
#include "header.h"

int main (void)
{
   puts (test ());
}
the compiler will see the same token stream as it would if program.c read
int x;
char *test (void);

int main (void)
{
   puts (test ());
}
The Next Discussion Will Be on Introduction to a various types of header files in brief. so stay connected with us.Readers One Important note for you (if any one wants to share there articles with us on any topic please click the link belowWrite for Us
Read More

The Bulid Process

Posted by Tushar Bedekar
Before Going more with this topic let us first understand what it is? Basically it is a process which takes place in order to build the .exe (executable file) from the code written in the editor or any integrated development environment.

Here this article is in the reference to the "C and C++ programming language".

C Source Code:-

The code that you have written in the editor is referred to as a source code.In "C Programming" language this source code is stored with an .c extension and in that if the C++ programming language it is being stored with the .cpp extension.

This source code includes many user

  • User defined functions   
  • Many library functions 
  • Macros Definition
  •  And native codes
for more info please refer Source Code Vs Object Code



Pre-compilation:-

Now this is the  first step in build process.During this step the C source code is get expanded on the basis of pre processor directives included in the sources code. These pre processor directives may include 
  • #include
  • #define
  • #ifdef and #pragma etc. 
During this pre compilation process the source code that is being stored in the .c format is get converted into the .I extension which is referred as the expanded source code.for example the stored in the form of tushar.c format is get converted into the form of tushar.I format. that means we can say the during the pre compilation only the extension or the format of the code changes in the first step if the build process.

Compilation:-

The remaining content will be updated within 10 hrs. so stay connected

Read More
back to top