Friday, 20 February 2015

How to coding in C (Lesson 3)

C Header files 

In the last lesson we saw how to declare a function in C.

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.
Any header file is often a file having file extension .h. Which is usually has C functionality declarations and macro definitions also to possibly be discussed concerning a number of supplier data.

Include syntax

it has following to forms
  1. # include<stdio.h>
  2. # include "stdio.h"

# include (Insert a particular header from another file) 

# include <stdio.h>

Example 
  1. #include                                //This is needed to run printf() function. 
  2. int main() 
  3. printf("C Programming");         //displays the content inside quotation 
  4. return 0; 
  5. }

Explanation how this program works

  1. Every program starts from main() function. 
  2. printf() is a library function to display output which only works if #include is included at the beginning.
  3.  Here, stdio.h is a header file (standard input output header file) and #include is command to paste the code from the header file when necessary. When compiler encounters printf() function and doesn't find stdio.h header file, compiler shows error. 
  4.  Code return 0; indicates the end of program. You can ignore this statement but, it is good programming practice to use return 0;.
Here are the list of header files 


 Any question about header files writes down in comment box. Everyday check this blog u will learn lot things of C programming and Web application development

1 comment: