Advertisement
Beginner C++, Preprocessor & Macros

What is the difference between #include with angle brackets and quotes?

Short answer

#include searches the system/standard include directories (used for standard and library headers). #include "name" searches the current directory first (then the system paths), used for your project's own headers. The distinction guides where the compiler looks for the file.

Save C++ mock interview
Advertisement
AModel answer
#include <name> searches the system/standard include directories (used for standard and library headers). #include "name" searches the current directory first (then the system paths), used for your project's own headers. The distinction guides where the compiler looks for the file.
#include <string>     // system/library header
#include "myclass.h"   // project header
Real-world example
Project headers use quotes so the compiler finds them relative to the source, while std headers use angle brackets.
Likely follow-ups
  • Where does each form search? | Which is for your own headers?
Related topics