What is the difference between #include<headerfile.h> and #inclu

What is the difference between #include<headerfile.h> and #inclu

Page 1 of 1

7 Replies - 8918 Views - Last Post: 28 February 2008 - 11:40 AM Rate Topic: -----

#1 asaljoha  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 27-February 08

What is the difference between #include<headerfile.h> and #inclu

Post icon  Posted 27 February 2008 - 05:44 PM

Hi can anyone explain to me What is the difference between #include<headerfile.h> and #include "headerfile.h"?

Thanks a lot..................
Is This A Good Question/Topic? 0
  • +

Replies To: What is the difference between #include<headerfile.h> and #inclu

#2 Tom9729  Icon User is offline

  • Segmentation fault
  • member icon

Reputation: 181
  • View blog
  • Posts: 2,642
  • Joined: 30-December 07

Re: What is the difference between #include<headerfile.h> and #inclu

Posted 27 February 2008 - 06:27 PM

You use quotes when you're specifying the path of the header file.

You use the "<...>" when the header file is in a system directory like /usr/include (Unix, in Windows I think it's somewhere in one of the system folders).

You can usually specify an additional include directory (so you can use the "<...>") as a compiler flag (depending on which compiler you use).

For example, since stdio.h is in my system's include path, I can include it by doing #include <stdio.h>. However it would also work if I used quotes and specified the path like this #include "/usr/include/stdio.h". :)
Was This Post Helpful? 0
  • +
  • -

#3 MorphiusFaydal  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 43
  • View blog
  • Posts: 1,376
  • Joined: 12-May 05

Re: What is the difference between #include<headerfile.h> and #inclu

Posted 27 February 2008 - 06:44 PM

The <...> are for system headers. (The default includes, like iostream, stdlib, etc.).

The "..." are for custom headers, i.e., ones you've written for your project.
Was This Post Helpful? 0
  • +
  • -

#4 asaljoha  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 27-February 08

Re: What is the difference between #include<headerfile.h> and #inclu

Posted 27 February 2008 - 06:54 PM

Thanks. it helps a lot.
Was This Post Helpful? 0
  • +
  • -

#5 Nayana  Icon User is offline

  • DIC Hawk - 나야나 नयन:
  • member icon

Reputation: 32
  • View blog
  • Posts: 824
  • Joined: 14-November 07

Re: What is the difference between #include<headerfile.h> and #inclu

Posted 27 February 2008 - 07:03 PM

A difference is that in the quoted form i.e. #include "something" the preprocessor will search the paths of all files in the project that include the same file.

With the angled bracket form, that is not done, it only searches the INCLUDE environment variable, and the path specified in the "/I" compiler option. The quoted form does this as well.

:) Have a codeful day

This post has been edited by Nayana: 27 February 2008 - 07:11 PM

Was This Post Helpful? 0
  • +
  • -

#6 selloorhari  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 68
  • Joined: 07-February 08

Re: What is the difference between #include<headerfile.h> and #inclu

Posted 28 February 2008 - 04:44 AM

#include <file>
This variant is used for system header files. It searches for a file named file in a standard list of system directories.
#include "file"
This variant is used for header files of your own program. It searches for a file named file first in the directory containing the current file, then in the quote directories and then the same directories used for <file>.
Check This link:

developer.apple.com/DOCUMENTATION/DeveloperTools/gcc-4.0.1/cpp/Header-Files.html#Header-Files

Was This Post Helpful? 0
  • +
  • -

#7 Tom9729  Icon User is offline

  • Segmentation fault
  • member icon

Reputation: 181
  • View blog
  • Posts: 2,642
  • Joined: 30-December 07

Re: What is the difference between #include<headerfile.h> and #inclu

Posted 28 February 2008 - 11:34 AM

Four nearly identical answers?

If ever a thead needed closing, this is it.
Was This Post Helpful? 0
  • +
  • -

#8 MorphiusFaydal  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 43
  • View blog
  • Posts: 1,376
  • Joined: 12-May 05

Re: What is the difference between #include<headerfile.h> and #inclu

Posted 28 February 2008 - 11:40 AM

View PostTom9729, on 28 Feb, 2008 - 12:34 PM, said:

Four nearly identical answers?

If ever a thead needed closing, this is it.


I think I streamlined your answer. :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1