written 6.5 years ago by
hetalgosavi
• 1.7k
|
•
modified 6.5 years ago
|
i) Header file:
- A file with extension .h
- It contains C function declarations and macro definitions to be shared between several source files.
- There are two types of header files: files that programmer writes and files that come with compiler.
- It is a simple practice in C or C++ programs to keep all constants, macros, system wide global variables and functions prototype in header file and include that header file whenever it is required.
- Example:
#include <stdio.h>
Here
#include
…. Preprocessor directive to call header file
<stdio.h>
…. Header file
ii) Macros:
- It is a collection of codes that is defined in C program by a name.
- It differs from function in sense that once a macro is defined by a name, the compiler will put the corresponding codes for it at every place where that macro name appears.
- Advantages of using macro are that the speed of execution of program increases. There is a decrease in the length of the program. Also there is a decrease in errors caused by repetitive coding.