`

c/c++中#include <>与#include""区别

阅读更多

<>先去系统目录中找头文件,如果没有在到当前目录下找。所以像标准的头文件 stdio.h、stdlib.h等用这个方法。


而""首先在当前目录下寻找,如果找不到,再到系统目录中寻找。 这个用于include自定义的头文件,让系统优先使用当前目录中定义的。



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 inclusion 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

INCLUDE=C:COMPILERINCLUDE;S:SOURCEHEADERS; 


using the #include  version of file inclusion, 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 inclusion 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 inclusion 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 inclusion is often used to include standard headers such as stdio.h or stdlib.h. This is because these headers are rarely (if ever) modified, and they should always be read from your compiler&rsquo;s standard include file directory.



  • The #include &ldquo;file&rdquo; method of file inclusion is often used to include nonstandard header 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 the preprocessor to use your newly modified version of the header rather than the older, unmodified version.

分享到:
评论

相关推荐

    #include和#include””的区别

    #include&lt; &gt;和#include””的区别 #include&lt;iostream&gt;与#include&lt;iostream.h&gt;区别 详细说明了之间的区别,对于理解之间的差别非常有用

    c++万能头文件(包含所有其他头文件)#include<bits/stdc++.h> 注:此cpp文件包含万能头文件以及基本框架

    #include &lt;algorithm&gt; #include &lt;bitset&gt; #include &lt;complex&gt; #include &lt;deque&gt; #include &lt;exception&gt; #include &lt;fstream&gt; #include &lt;functional&gt; #include &lt;iomanip&gt; #include &lt;ios&gt; #include &lt;iosfwd&gt; #include ...

    第四次上机题目及参考代码.docx

    #include&lt;stdio.h&gt; #include &lt;sys/types.h&gt; #include &lt;sys/stat.h&gt; #include &lt;fcntl.h&gt; #include&lt;stdlib.h&gt; #include &lt;sys/ioctl.h&gt; #include &lt;sys/soundcard.h&gt; #include &lt;termios.h&gt; #include &lt;unistd.h&gt; int ...

    visual studio中若要使用#include ,需手动添加头文件:stdc++.h

    visual studio中,若要使用#include &lt;bits/stdc++.h&gt;,则需手动添加头文件:stdc++.h,visual studio不自带,#include &lt;bits/stdc++.h&gt;是万能头文件,在平时自己敲代码或者online judge懒得一行一行敲头文件的时候都...

    C++班级成员信息管理

    #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;malloc.h&gt; #include &lt;string.h&gt; typedef struct Student//学生信息 { signed short id; char name[11]; char sex[7]; signed short age; char telNum...

    c/c++ windows ble 蓝牙操作

    c/c++ windows 通过winrt操作ble 蓝牙 #include &lt;windows.h&gt; #include &lt;iostream&gt; #include &lt;winrt/Windows.Foundation.h&gt; #include &lt;winrt/Windows.Foundation.Collections.h&gt; #include &lt;winrt/Windows.Devices....

    C/C++头文件一览

    #include &lt;assert.h&gt; //设定插入点 #include &lt;ctype.h&gt; //字符处理 #include &lt;errno.h&gt; //定义错误码 #include &lt;float.h&gt; //浮点数处理 #include &lt;fstream.h&gt; //文件输入/输出 #include &lt;iomanip.h&gt; //参数化...

    C++程序设计-最新.pdf

    1) 创建一个控制台项目 选择菜单 File"New, 在 Projects 标签下选择 Windows32 Console Application, 输入 项目名称"circle",然后按 OK 2) 在项目中增加一个文件 选择菜单 File"New, 在 Files 标签下选择 C/C++ ...

    C/C++语言头文件(全)

    #include &lt;assert.h&gt; //设定插入点 #include &lt;ctype.h&gt; //字符处理 #include &lt;errno.h&gt; //定义错误码 #include &lt;float.h&gt; //浮点数处理 #include &lt;fstream.h&gt; //文件输入/输出 #include &lt;iomanip.h&gt; //参数化...

    C和C++头文件对比一览

    #include &lt;clocale&gt; #include &lt;cmath&gt; #include &lt;complex&gt; //复数类 #include &lt;cstdio&gt; #include &lt;cstdlib&gt; #include &lt;cstring&gt; #include &lt;ctime&gt; #include &lt;deque&gt; //STL 双端队列容器 #include &lt;exception&gt; //...

    Eclipse添加C/C++头文件跳转

    Eclipse 中新建C 或C ++到项目时,头文件报警,显示“Unresolved inclusion:&lt;stdio&gt;” 虽然不影响项目到编译和运行,确也无法查看头文件,让人感觉实在不爽。下面是在国外到网站上看到解决方案,自己整理了一下拿来...

    c++头文件(传统头文件标准头文件)

    C、传统 C++ #include &lt;assert.h&gt; //设定插入点 #include &lt;ctype.h&gt; //字符处理 #include &lt;errno.h&gt; //定义错误码 #include &lt;float.h&gt; //浮点数处理 #include &lt;fstream.h&gt; //文件输入/输出 ...#include &lt;cerrno&gt;

    HuffmanCoding.cpp

    #include&lt;iostream&gt; #include&lt;string&gt; #include&lt;iomanip&gt; using namespace std; struct HNode { int weight; int parent; int LChild; int RChild; }; struct HCode { char data; char code[1000]; }; class...

    C++函数库大全

    #include &lt;assert.h&gt; //设定插入点 #include &lt;ctype.h&gt; //字符处理 #include &lt;errno.h&gt; //定义错误码 #include &lt;float.h&gt; //浮点数处理 #include &lt;fstream.h&gt; //文件输入/输出 #include &lt;iomanip.h&gt; //...

    猜数字 C++ #include<stdio.h>

    这是一个小游戏实现猜数字的小游戏,采用的语言是C++。

    c语言库函数使用大全及头文件介绍

    C、传统 C++ #include &lt;assert.h&gt; //设定插入点 #include &lt;ctype.h&gt; //字符处理 #include &lt;errno.h&gt; //定义错误码 #include &lt;float.h&gt; //浮点数处理 #include &lt;fstream.h&gt; //文件输入/输出 #include &lt;iomanip...

    小球碰撞代码c++

    #include &lt;math.h&gt; // Header File For Math Library Routines #include &lt;stdio.h&gt; // Header File For Standard I/O Routines #include &lt;stdlib.h&gt; // Header File For Standard Library #include &lt;gl\gl.h&gt; ...

    基于Opencv实现双目摄像头拍照程序

    本文实例为大家分享了Opencv实现双目摄像头拍照程序的具体代码,供大家...#include&lt;iostream&gt; #include&lt;string&gt; #include&lt;sstream&gt; #include&lt;opencv2&gt; #include&lt;opencv2&gt; #include&lt;opencv2&gt; #include&lt;opencv2/ope

    c++五子棋制作代码 设计

    基于c++的五#include&lt;iostream&gt; #include&lt;cstdlib&gt; using namespace std; const char outstr[11][4]={"┌","┬","┐","├","┼","┤","└","┴","┘","○","●"}; int com[15][15],luozi[15][15]; int c,d; void ...

    自己制作的一个《学霸模拟器》

    #include&lt;bits/stdc++.h&gt;#include&lt;stdio.h&gt;#include&lt;windows.h&gt;#include&lt;conio.h&gt;#include&lt;stdlib.h&gt;#include&lt;time.h&gt;#define LEN 30#define WID 25#include&lt;bits/stdc++.h&gt;#include&lt;iostream&gt;#include&lt;fstream&gt;#...

Global site tag (gtag.js) - Google Analytics