Difference between # include and # include "in C/C ++

Source: Internet
Author: User
<> First, find the header file in the system directory. If the file is not found in the current directory. So use this method like standard header files stdio. h and stdlib. h.

"" Is first searched in the current directory. If it cannot be found, it is then searched in the system directory. This header file is used to include custom headers so that the system gives priority to the files defined in the current directory.

When writing your C program, you can include files in two ways. the first way is to surround the file you want to include with the angled brackets <and>. this method of definition tells the Preprocessor to look for the file in the predefined default location.

This predefined default location is often an include environment variable that denotes the path to your include files. For instance, given the include variable

C code
  1. Include = C: compilerinclude; s: sourceheaders;

Using the # include version of File Inclusion Sion, the compiler first checks the C: compilerinclude
Directory for the specified file. If the file is not found there, the compiler then checks the S: sourceheaders directory. If the file is still not found, the Preprocessor checks the current directory.

The second way to include files is to surround the file you want to include with double quotation marks. this method of permission sion tells the Preprocessor to look for the file in the current directory first, then look for it in the predefined locations you have
Set up.

Using the # include & ldquo; file & rdquo; version of file authentication sion and applying it to the preceding example, The Preprocessor first checks the current directory for the specified file. if the file is not found in the current directory, the C: compilerinclude directory
Is searched. If the file is still not found, the Preprocessor checks the S: sourceheaders directory.

  • The # include method of File compression sion is often used to includeStandardHeaders such as stdio. h or stdlib. H. This is because these headers are rarely (if ever) modified, and they shoshould always be read from your compiler & rsquo; s standard include file
    Directory.
  • The # include & ldquo; file & rdquo; method of File compression sion is often used to includeNonstandardHeader files that you have created for use in your program. This is because these headers are often modified in the current directory, and you will want
    Preprocessor to use your newly modified version of the header rather than the older, unmodified version.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.