The <> form skips the current directory and goes right to the place standard hearders are located. The "" form first checks the current directory, then the standard headers. The "" form is normally used for headers you write (and keep in your project directory). You can also make replacements for standard headers this way. If you write a file called iostream.h and put it in your project directory, #include "iostream.h" will include your file if it can find it, and the system one if it can't; #include <iostream.h> will include the file located in the standard include path in every case.
By the way, never use iostream.h; it's not a part of standard C++ and provided only for backwards compatibility. Use iostream (without the ".h" instead.
qednick - it depends on the compiler. Some have default include paths and will pick up the stuff in the compiler's include directory. It depends on what the default include paths are. This is sometimes set in the environment variables.
May I add some words? <> form is not "skipped current directory" only. C++ Standard defines that <header> points to the embedded, standard header implementation. It may be not an ordinal text file in any directory but compiler-embedded database reference or what else...
So, <> form must be used for language-defined headers only, and quoted form for user-defined headers.
It's right, .h suffix excluded now for standard headers. For example, <iostream.h> points to "old stream library" in some C++ compilers. Sometimes they implements both "old" and true standard "new" <iostream> headers (libraries). They are incompatible.
Yup, that's true; the standard headers need not be actual files, so there may not be an actual path to them. The underlying principle remains the same, however; <> goes right to the standard include "files" (whether or not they're actual files), while "" checks files in (actually, relative to) the the current directory before checking the standard ones (which, again, may not be true files).
To get really technical, there's nothing that says the "" form has to search the current directory (since theoretically, there may not even be such a thing as a directory on every platform), but in practice, that's where it usually looks.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.