c++ include difference between quotes and brackets

The use of quotes and brackets in C++ for including header files determines the search strategy for locating the specified file.

  1. Using Quotes:
  2. Syntax: #include "filename"
  3. The preprocessor searches for the specified file in the current directory first. If the file is not found, it searches in the standard system directories.

  4. Using Brackets:

  5. Syntax: #include <filename>
  6. The preprocessor searches for the specified file only in the standard system directories. It does not consider the current directory.

In summary, using quotes ("filename") allows the preprocessor to search in the current directory before the standard directories, while using brackets (<filename>) restricts the search to the standard system directories only.