Procecessor Directive : #include

The #include preprocessor is used to include header files to a C program. The syntax of #include is :
 #include <head_file_name>
#include "header_file_name"
Where the header_file_name is name of the header file.

Also note that in first syntax the < > sign is used to include header file and in the second syntax " " (double column) sign. The main difference between these two syntax is that, if header is included within <>, then the preprocessor will search a predetermined directory path to locate the header file. And if the header file is enclosed in "", the preprocessor will look for the header file in the same directory as the source file.

Example :

Filename : myheader.h
#define PI 3.14

float area(int rad) {
  float ans = 2*PI*(rad*rad);
  return ans;
Filename : test.c
#include "myheader.h"

int main() {
  int rad = 5;
  printf("Area : %.2f\n", area(5));
  return 0;
Output :

Area : 157.00

Next : C Language Tutorials List