What is the difference between #include &lt filename &gt and #include “filename” ?

#include directive is used for the inclusion of the additional files (e.g. standard header files) to our own program.
There are two ways for using the #include directive :

 
1. #include <filename> // with angle brackets
2. #include “filename” // with quotes

 

When we use angle brackets (< >) in a #include statement, it tells the compiler to search the filename in the predefined standard header directories. This is generally used when we want to include a standard header file.

For example, if we want to include stdio.h or iostream.h then the #include statement look like :

#include<stdio.h>
#include<iostream.h>

If we use simple quotes ( “ ” ) instead of the angle brackets (< >) in a #include statement, the compiler search the filename in the current local directories. This is useful when we wrote our own header file or want to include another source code to our program.

 

For example, suppose we wrote our own header file named as progprashn.h and we want to include it in our code then the #include statement look like :

#include“progprashn.h”

When #include “filename” is used, compiler first search current directory for the file. If the file is not found there, the compiler then checks the predefined directory. So if someone uses #include “stdio.h” instead of #include<stdio.h> both cause the compiler to include the standard I/O header file to the program.

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.