Ok, so I have a stupid question to ask, and I aks all of you not to ridicule one who is merely looking for knowledge.

What is the difference between using

#include "whatever"

versus using

#include <whatever>

? I've always used the brackets versus the quotes, and have tried looking into google, but when searching for something like "#include """ there are a lot of results that come up with a lot of other forums and such where there's a line in their code that reads "#include"... so I don't know where to look for this stuff...


Thanks. :)

The difference depends on the compiler you are using. Some compilers treat them the same, while others don't. With vc++ the <> tells the compiler to only look in its standard include directories (there are options to add to the list of directories), while the "" tells the compiler to first look in the program's source directory, it the header file is not there then the compiler will look in its standard directories just as if you had used <>.

I think google made a recent change to its search algorithms because some things seem to be more difficult to find than previously.

Edited 5 Years Ago by Ancient Dragon: n/a

Using quotes ("blah") instead of angle-brackets (<blah>) changes the compiler's behavior while it searches for the #included file.

Using quotes makes the compiler look in the source file's local directory, then the default include directory. Using angle-brackets makes the compiler go directly to the default include directory and ignore the local directory when it searches.

Basically, if you're writing a custom header, you should use quotes (i.e. "myClass.h") and use brackets for any standard headers (i.e. <iostream>, <cstdlib>, etc.).

See this.

EDIT:
Oops, AD beat me to it.

Edited 5 Years Ago by Fbody: n/a

The standard says that angle brackets cause the compiler to look in an implementation-defined location and double quotes cause the compiler to look in an implementation-defined location. I can see how there might be confusion. ;)

Traditionally the angle brackets searched the compiler's include locations followed by local directories, while double quotes did the opposite. Best practice has been to use angle brackets for compiler provided headers and double quotes for everything else.

This question has already been answered. Start a new discussion instead.