To learn how to use the # include command in VC to include the path searched by the header file, you must first understand several paths in VC:
1. System Path
In VC, the system path is the path specified by "include files" in "tools-> options-> directories.
Open this dialog box and you will find these paths by default:
C: \ Program Files \ Microsoft Visual Studio \ vc98 \ include
C: \ Program Files \ Microsoft Visual Studio \ vc98 \ MFC \ include
C: \ Program Files \ Microsoft Visual Studio \ vc98 \ ATL \ include
We can add it here, so that the path we add will also become the system path. The added format must follow the preceding instructions.
2. Current path
The current path refers to the path of the project file in the VC project, that is, the path of the. DSW file.
Many friends on the Internet say that the current path refers to the path where the. cpp file is located. This statement is correct after testing. However, it is incorrect when compiling with VC.
3. Additional path
An additional path is the path specified in "Project-> Settings-> C/C ++-> Preprocessor-> additional include directories.
This path is empty by default. You can enter the required path here. For example, enter "C: \ 123 \" here (no quotation marks ), then the additional path will become "C: \ 123 \".
We can edit the above 1, 3 path by ourselves. You can use absolute or relative paths during editing.
For example, when adding a system path, you can enter the following:
. \ SRC \ indicates the SRC folder in the current directory;
.. \ SRC \ indicates the SRC folder in the previous directory of the current directory;
.. \ SRC \ indicates that the path of .. \ SRC \ in the current directory already overlaps with the first one.
VC will automatically convert the relative path into an absolute path.
When an additional path is added, the relative path and system path are the same.
Use the # include command in VC in three forms:
1. # include <file. h>
When VC executes this command, it searches for the file. h file in the system directory.
In this bar code command, VC does not search for files in the current path or additional path.
2. # include "file. H"
When VC executes this command, it first searches for the additional path. If not, it searches for the system path. If not, it searches for the current path.
3. # include "directory \ file. H"
When VC executes this command, it will go to the specified path to find the file. If not, it will not continue searching.