when the header file is included in the program? Possible duplicate: what is the difference between #inc...">

What is the difference between "" and <> when the header file is included in the program?

Possible duplicate:
what is the difference between #include <filename> and #include "filename"

I would like to know what is the difference between

 #include "stdio.h" 

and

 #include <stdio.h> 
+4
source share
3 answers

Use <whatever> for system headers and "whatever" for your own headers.

The difference is that when it is enclosed in quotation marks, the compiler will search in the local directory, but with <> it will not. If you want technical information, the C standard does not guarantee this, but this is how all compilers work.

+11
source

"" searches the current file path. <> performs a search on global paths.

Edit: You set the absolute path and relative path.

Suppose you have a file structure as follows:

 folderX -fileX.a -fileX.b -folderX.Y -fileX.Ya -fileX.Yb -folderX.Z -fileX.Za 

Then the absolute path of fileX.Za will be folderX/folderX.Z/fileX.Za , assuming that folderX is the most accessible directory available. The relative path of fileX.Za relative, for example, fileX.a is only part of folderX.Z/fileX.Za , i.e. you run the path in the directory where fileX.a is located.

+5
source
 #include <file> 

This option is used for system header files. It searches for a file named file in the standard list of system directories. You can add directories to this list with the -I option.

 #include "file" 

This option is used for header files of your own program. It searches for a file named file first in the directory containing the current file, then in the same directories for which it is used.

The #include argument, delimited by quotation marks or angle brackets, behaves like a string constant in that comments are not recognized and macro names are not expanded. Thus, #include indicates the inclusion of a system header file named `x / * y '.

However, if backslashes occur inside the file name, they are considered regular text characters, not escape characters. None of the escape sequences for characters corresponding to string constants in C were processed.

Link :

+3
source

Source: https://habr.com/ru/post/1342251/


All Articles