C include 與 有什麼區別?

時間 2021-05-29 22:57:46

1樓:1562309321

搜尋的範圍不一樣,<>只搜尋編譯器自帶的函式庫,找不到直接報錯。「」先搜尋自定義的檔案,找不到再從自定義函式庫找,找不到報錯。

2樓:暮無井見鈴

從標準來看……

n4659, 19.2 Source file inclusion, 2

A preprocessing directive of the form

# include < h-char-sequence > new-line

searches a sequence of implementation-defined places for a header identified uniquely by the specified sequence between the < and > delimiters, and causes the replacement of that directive by the entire contents of the header. How the places are specified or the header identified is implementation-defined.

擁有此形式的預處理指令

# include < h-char-sequence > new-line

於一串行實現定義位置,查詢由 < 與 > 分隔符之間的序列所唯一標識的標頭檔案,並導致該指令為標頭檔案的整體內容所替換。位置如何指定,或標頭檔案如何標識,是實現定義的。

n4659, 19.2 Source file inclusion, 3

A preprocessing directive of the form

# include " q-char-sequence " new-line

causes the replacement of that directive by the entire contents of the source file identified by the specified sequence between the " delimiters. The named source file is searched for in an implementation-defined manner. If this search is not supported, or if the search fails, the directive is reprocessed as if it read

# include < h-char-sequence > new-line

with the identical contained sequence (including > characters, if any) from the original directive.

擁有此形式的預處理指令

# include " q-char-sequence " new-line

導致該指令為 " 分隔符間的序列所標識的原始檔的整體內容所替換。指名的原始檔以實現定義行為查詢。若不支援此查詢,或若查詢失敗,則此指令以如同它從原指令,以相同的所含序列讀取

# include < h-char-sequence > new-line

(包含 > 字元,若它存在)。

(C11 標準裡也有一模一樣的話)

簡言之 #include <> 和 #include "" 都會在實現定義的位置查詢檔案,並將其包含。

區別是若 #include "" 查詢成功,則遮蔽 #include <> 所能找到的同名檔案;否則再按照 #include <> 的方式查詢檔案。另外標準庫標頭檔案都放在 #include <> 所查詢的位置。

一般來說 #include <> 的查詢位置是標準庫標頭檔案所在目錄, #include "" 的查詢位置是當前原始檔所在目錄。不過這些都可由編譯器呼叫引數等配置更改。

3樓:

摘錄自c/c++中#include <>與#include""區別

<>先去系統目錄中找標頭檔案,如果沒有在到當前目錄下找。所以像標準的標頭檔案 stdio.h、stdlib.h等用這個方法。

而""首先在當前目錄下尋找,如果找不到,再到系統目錄中尋找。 這個用於include自定義的標頭檔案,讓系統優先使用當前目錄中定義的。

Prof Dr 與 Prof 有什麼區別?

無無 Doctor是博士。小 中 大學生,其中大學生又包含專科 本科 學士 碩士 博士,是學位的最高等級,通俗講就是最高文憑的學生 更高的還有國家科學院評的院士,但那不是靠學習就能拿到的 professor是教授。教師中的某一級職稱,大學裡也不全是教授,大多數只能算講師 助教 導師等等。相互之間沒有...

抄襲與借鑑有什麼區別?

喜歡叫借鑑,不喜歡叫抄襲。大部分人的邏輯 還有,一部作品多多少少都會有那麼一點點雷同的文字,您看看,被爆抄襲的不都一般是火了的作品嘛?沒火的也有抄襲,不過一般是很明顯的。火了的被爆抄襲概率很大,因為關注的人多了,很多雙眼睛盯著看,難免會挑到骨頭。題外話 ABCD歌是不是抄襲小星星的曲?人家那叫借鑑 ...

宗教與哲學有什麼區別?

面壁壬 它們都以人們所謂的真理為物件。但是 宗教與哲學對待真理的基本態度有著本質區別。宗教要求人相信,哲學要求人懷疑。宗教在根本問題上是不允許人問的,而哲學恰恰相反,越是根本的問題就越是要問。 曲曲 根本區別在乙個有神,乙個無神 宗教是統治者製造出來的,造出乙個神,好用來統治人民。哲學是科學的科學,...