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.
- Using Quotes:
- Syntax:
#include "filename"
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.
Using Brackets:
- Syntax:
#include <filename>
- 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.