What is the difference between #include <file>
and #include "file"
in C?
a) Angle brackets are for system files, quotes are for user-defined files
b) There is no difference
c) Quotes are for system files, angle brackets are for user-defined files
d) Both include the same file type
Answer:
a) Angle brackets are for system files, quotes are for user-defined files
Explanation:
In C, the #include
directive can be used with either angle brackets < >
or double quotes " "
. When using angle brackets, the preprocessor searches for the file in the standard system directories (typically used for including standard library headers like stdio.h
). When using double quotes, the preprocessor searches for the file in the current directory first, and if it is not found, it may search in the system directories.
This distinction allows for a clear separation between standard library headers and user-defined headers, making it easier to manage and organize code.