Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 18-11-2009
Member
 
Join Date: Jan 2009
Posts: 30
Why we use Header Files

I am just started the 'c' programming. I am getting confused regarding the header files which we use at the begining of program.

Should we have to include header files in all programs? OR it is optional.
Can anyone know what are different header file?
Reply With Quote
  #2  
Old 19-11-2009
Member
 
Join Date: Apr 2008
Posts: 1,948
Re: Why we use Header Files

A Header file is a file which contains C declarations as well as definitions of macro to be shared between many source files. we request the use of a header files in our program code by including it along with the C pre-processor directive i.e`#include'.

Below are the use of header files

1. Header files of system declares the interfaces to parts of the operating system. We include them in our program code to pass the definitions & declarations we need to invoke calls of system and libraries of system.

2. our own header files includes declarations for interfaces between the program source files.
Every time we have a group of related declarations & definitions or more of which are needed in many different program source files,So it's a good to create a header files for them.
Reply With Quote
  #3  
Old 19-11-2009
Member
 
Join Date: May 2008
Posts: 2,008
Re: Why we use Header Files

According to my knowledge, a header files are used to declares variables, constants and functions which may be common to many applications.

When a system comprises of multiple applications that all access the same data which becomes very essential that each and every application uses similar definitions .So it is also safer for all of those applications to use the similar methods for reading that data.

I hope this information will give you the idea about header files..
Reply With Quote
  #4  
Old 19-11-2009
Member
 
Join Date: Apr 2008
Posts: 2,001
Re: Why we use Header Files

Hi friend,

The main use of header file is it is used to share information within various files.

1.Suppose, if you have several functions say three functions named as A1, A2, A3, f4 which are placed in file 'abc.c' and if all the functions want to get accessed by each other then all functions must be placed within same file 'abc.c'.

2. see the another example, if there is a function 'A4' placed in another file say 'xyz.c' and if the function A1 placed in 'abc.c' wants to access the 'A4' function placed in 'xyz.c',then it is impossible.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Why we use Header Files"
Thread Thread Starter Forum Replies Last Post
Connect USB 3.0 front case panel header to motherboard w/o a header? Dogs-Day-Out Motherboard Processor & RAM 4 14-04-2012 07:02 PM
Header files of Java Ram Bharose Software Development 5 30-12-2009 11:44 AM
IIS7: Add expires header or cache-control header quota Software Development 3 06-06-2009 07:45 PM
Help Regarding Header Files Jagdish Gada Software Development 4 06-03-2009 12:58 PM
Compiler Error in Visual Studio 6,while adding OpenGL as header files. Santanio Software Development 2 12-01-2009 08:40 PM


All times are GMT +5.5. The time now is 01:54 AM.