Results 1 to 4 of 4

Thread: Why we use Header Files

  1. #1
    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?

  2. #2
    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.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    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..

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    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.

Similar Threads

  1. Connect USB 3.0 front case panel header to motherboard w/o a header?
    By Dogs-Day-Out in forum Motherboard Processor & RAM
    Replies: 4
    Last Post: 14-04-2012, 07:02 PM
  2. Header files of Java
    By Ram Bharose in forum Software Development
    Replies: 5
    Last Post: 30-12-2009, 11:44 AM
  3. IIS7: Add expires header or cache-control header
    By quota in forum Software Development
    Replies: 3
    Last Post: 06-06-2009, 07:45 PM
  4. Help Regarding Header Files
    By Jagdish Gada in forum Software Development
    Replies: 4
    Last Post: 06-03-2009, 12:58 PM
  5. Replies: 2
    Last Post: 12-01-2009, 08:40 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,037,715.71175 seconds with 17 queries